src/main/java/de/blau/android/presets/AutoPreset.java
/**
     * Add an PresetItem to the auto preset
     * 
     * @param ctx an Android Context
     * @param item the PresetItem
     * @return true if successful
     */
Add an PresetItem to the auto preset

@param ctx an Android Context
@param item the PresetItem
@return true if successful
Add an PresetItem to the auto preset @param ctx an Android Context @param item the PresetItem @return true if successful
public static boolean addItemToAutoPreset(@NonNull Context ctx, @NonNull PresetItem item) {
        Preset[] configuredPresets = App.getCurrentPresets(ctx);
        int autopresetPosition = configuredPresets.length - 1;
        Preset preset = configuredPresets[autopresetPosition];
        if (preset == null) {
            AdvancedPrefDatabase.createEmptyAutoPreset(ctx, configuredPresets, autopresetPosition);
            preset = configuredPresets[autopresetPosition];
        }
        if (preset != null) {
            PresetGroup group = preset.getGroupByName(ctx.getString(R.string.preset_autopreset));
            if (group != null) {
                @SuppressWarnings("unused")
                PresetItem newItem = new PresetItem(preset, group, item);
                AutoPreset.save(ctx, preset);
                return true;
            }
        }
        Log.e(DEBUG_TAG, "Preset null or group not found");
        return false;
    }
public static boolean addItemToAutoPreset ( @ NonNull Context ctx , @ NonNull PresetItem item ) { Preset [ ] configuredPresets = App . getCurrentPresets ( ctx ) ; int autopresetPosition = configuredPresets . length - 1 ; Preset preset = configuredPresets [ autopresetPosition ] ; if ( preset == null ) { AdvancedPrefDatabase . createEmptyAutoPreset ( ctx , configuredPresets , autopresetPosition ) ; preset = configuredPresets [ autopresetPosition ] ; } if ( preset != null ) { PresetGroup group = preset . getGroupByName ( ctx . getString ( R . string . preset_autopreset ) ) ; if ( group != null ) { @ SuppressWarnings ( "unused" ) PresetItem newItem = new PresetItem ( preset , group , item ) ; AutoPreset . save ( ctx , preset ) ; return true ; } } Log . e ( DEBUG_TAG , "Preset null or group not found" ) ; return false ; }
Add an PresetItem to the auto preset
Add an PresetItem to the auto preset
// may happen during testing