src/main/java/de/blau/android/propertyeditor/tagform/ComboDialogRow.java
/**
     * Build a dialog for selecting a single value or none via a scrollable list of radio buttons
     * 
     * @param caller the calling TagFormFragment instance
     * @param key the key
     * @param adapter the ArrayAdapter holding the values
     * @param row the row we are started from
     */
Build a dialog for selecting a single value or none via a scrollable list of radio buttons

@param caller the calling TagFormFragment instance
@param key the key
@param adapter the ArrayAdapter holding the values
@param row the row we are started from
Build a dialog for selecting a single value or none via a scrollable list of radio buttons @param caller the calling TagFormFragment instance @param key the key @param adapter the ArrayAdapter holding the values @param row the row we are started from
private static void buildImageComboDialog(@NonNull final TagFormFragment caller, @NonNull final String key, @NonNull final ArrayAdapter<?> adapter,
            @NonNull final DialogRow row) {
        String value = row.getValue();
        ArrayList<String> images = new ArrayList<>();
        final List<Value> values = new ArrayList<>();
        for (int i = 1; i < adapter.getCount(); i++) {
            Object o = adapter.getItem(i);
            if (o instanceof Ruler) {
                continue;
            }
            final Value aValue = o instanceof Value ? ((Value) o) : new StringWithDescription((String) o);
            values.add(aValue);
            if (o instanceof StringWithDescriptionAndIcon && ((StringWithDescriptionAndIcon) o).hasImagePath()) {
                images.add(((StringWithDescriptionAndIcon) o).getImagePath());
            } else {
                images.add("");
            }
        }
        int pos = 0;
        for (int i = 0; i < values.size(); i++) {
            if (values.get(i).getValue().equals(value)) {
                pos = i;
                break;
            }
        }
        SelectByImageFragment.showDialog(caller, images, pos, new ComboImageLoader(key, values));
    }
private static void buildImageComboDialog ( @ NonNull final TagFormFragment caller , @ NonNull final String key , @ NonNull final ArrayAdapter < ? > adapter , @ NonNull final DialogRow row ) { String value = row . getValue ( ) ; ArrayList < String > images = new ArrayList < > ( ) ; final List < Value > values = new ArrayList < > ( ) ; for ( int i = 1 ; i < adapter . getCount ( ) ; i ++ ) { Object o = adapter . getItem ( i ) ; if ( o instanceof Ruler ) { continue ; } final Value aValue = o instanceof Value ? ( ( Value ) o ) : new StringWithDescription ( ( String ) o ) ; values . add ( aValue ) ; if ( o instanceof StringWithDescriptionAndIcon && ( ( StringWithDescriptionAndIcon ) o ) . hasImagePath ( ) ) { images . add ( ( ( StringWithDescriptionAndIcon ) o ) . getImagePath ( ) ) ; } else { images . add ( "" ) ; } } int pos = 0 ; for ( int i = 0 ; i < values . size ( ) ; i ++ ) { if ( values . get ( i ) . getValue ( ) . equals ( value ) ) { pos = i ; break ; } } SelectByImageFragment . showDialog ( caller , images , pos , new ComboImageLoader ( key , values ) ) ; }
Build a dialog for selecting a single value or none via a scrollable list of radio buttons
Build a dialog for selecting a single value or none via a scrollable list of radio buttons
// Note we can't use the adapter directly in the ImageLoader as it will potentially be serialized // Start with 1 to avoid empty entry