src/main/java/de/blau/android/presets/PresetItem.java
/**
     * Adds a recommended or optional tag to the item and populates autosuggest
     * 
     * @param optional true if optional, false if recommended
     * @param key key name of the tag
     * @param type type of preset field
     * @param value value string from the XML (delimiter-separated list if more than one possible values)
     * @param displayValue matching display value for value (same format for more than one)
     * @param shortDescriptions matching short description for value (same format for more than one)
     * @param delimiter the delimiter if more than one value is present
     * @param matchType the applicable MatchType
     * @return the allocated PresetField
     */
Adds a recommended or optional tag to the item and populates autosuggest


Adds a recommended or optional tag to the item and populates autosuggest
@NonNull
    public PresetField addTag(boolean optional, @NonNull String key, PresetKeyType type, @Nullable String value, @Nullable String displayValue,
            @Nullable String shortDescriptions, final String delimiter, MatchType matchType) {
        String[] valueArray = (value == null) ? new String[0] : value.split(Pattern.quote(delimiter));
        String[] displayValueArray = (displayValue == null) ? new String[0] : displayValue.split(Pattern.quote(delimiter));
        String[] shortDescriptionArray = (shortDescriptions == null) ? new String[0] : shortDescriptions.split(Pattern.quote(delimiter));
        StringWithDescription[] valuesWithDesc = new StringWithDescription[valueArray.length];
        boolean useDisplayValues = valueArray.length == displayValueArray.length;
        boolean useShortDescriptions = !useDisplayValues && valueArray.length == shortDescriptionArray.length;
        for (int i = 0; i < valueArray.length; i++) {
            String valueDescription = null;
            if (useDisplayValues) {
                valueDescription = displayValueArray[i];
            } else if (useShortDescriptions) {
                valueDescription = shortDescriptionArray[i];
            }
            valuesWithDesc[i] = new StringWithDescription(valueArray[i], valueDescription);
        }
        return addTag(optional, key, type, valuesWithDesc, delimiter, matchType);
    }
@ NonNull public PresetField addTag ( boolean optional , @ NonNull String key , PresetKeyType type , @ Nullable String value , @ Nullable String displayValue , @ Nullable String shortDescriptions , final String delimiter , MatchType matchType ) { String [ ] valueArray = ( value == null ) ? new String [ 0 ] : value . split ( Pattern . quote ( delimiter ) ) ; String [ ] displayValueArray = ( displayValue == null ) ? new String [ 0 ] : displayValue . split ( Pattern . quote ( delimiter ) ) ; String [ ] shortDescriptionArray = ( shortDescriptions == null ) ? new String [ 0 ] : shortDescriptions . split ( Pattern . quote ( delimiter ) ) ; StringWithDescription [ ] valuesWithDesc = new StringWithDescription [ valueArray . length ] ; boolean useDisplayValues = valueArray . length == displayValueArray . length ; boolean useShortDescriptions = ! useDisplayValues && valueArray . length == shortDescriptionArray . length ; for ( int i = 0 ; i < valueArray . length ; i ++ ) { String valueDescription = null ; if ( useDisplayValues ) { valueDescription = displayValueArray [ i ] ; } else if ( useShortDescriptions ) { valueDescription = shortDescriptionArray [ i ] ; } valuesWithDesc [ i ] = new StringWithDescription ( valueArray [ i ] , valueDescription ) ; } return addTag ( optional , key , type , valuesWithDesc , delimiter , matchType ) ; }
Adds a recommended or optional tag to the item and populates autosuggest
Adds a recommended or optional tag to the item and populates autosuggest