src/main/java/de/blau/android/presets/PresetMRUInfo.java
/**
     * Add MRUs to a PresetGroup sorting the paths by the timestamp
     * 
     * This is slightly complex because PresetELementPath is relative to the presets root group
     * 
     * @param group the PresetGroup
     * @param presets the Presets with the MRUs
     * @param region the current region if any
     */
Add MRUs to a PresetGroup sorting the paths by the timestamp

This is slightly complex because PresetELementPath is relative to the presets root group

@param group the PresetGroup
@param presets the Presets with the MRUs
@param region the current region if any
Add MRUs to a PresetGroup sorting the paths by the timestamp This is slightly complex because PresetELementPath is relative to the presets root group @param group the PresetGroup @param presets the Presets with the MRUs @param region the current region if any
public static void addToPresetGroup(@NonNull PresetGroup group, @NonNull Preset[] presets, @Nullable String region) {
        Map<TimestampedPresetElementPath, Preset> parent = new HashMap<>();
        List<TimestampedPresetElementPath> paths = new ArrayList<>();
        for (Preset p : presets) {
            if (p != null && p.hasMRU()) {
                for (TimestampedPresetElementPath path : p.getMru().recentPresets) {
                    paths.add(path);
                    parent.put(path, p);
                }
            }
        }
        Collections.sort(paths, (TimestampedPresetElementPath p1, TimestampedPresetElementPath p2) -> Long.compare(p2.getTimestamp(), p1.getTimestamp()));
        for (PresetElementPath path : paths) {
            final PresetItem item = (PresetItem) Preset.getElementByPath(parent.get(path).getRootGroup(), path, region, false);
            if (item != null) {
                group.addElement(item, false);
            }
        }
    }
public static void addToPresetGroup ( @ NonNull PresetGroup group , @ NonNull Preset [ ] presets , @ Nullable String region ) { Map < TimestampedPresetElementPath , Preset > parent = new HashMap < > ( ) ; List < TimestampedPresetElementPath > paths = new ArrayList < > ( ) ; for ( Preset p : presets ) { if ( p != null && p . hasMRU ( ) ) { for ( TimestampedPresetElementPath path : p . getMru ( ) . recentPresets ) { paths . add ( path ) ; parent . put ( path , p ) ; } } } Collections . sort ( paths , ( TimestampedPresetElementPath p1 , TimestampedPresetElementPath p2 ) -> Long . compare ( p2 . getTimestamp ( ) , p1 . getTimestamp ( ) ) ) ; for ( PresetElementPath path : paths ) { final PresetItem item = ( PresetItem ) Preset . getElementByPath ( parent . get ( path ) . getRootGroup ( ) , path , region , false ) ; if ( item != null ) { group . addElement ( item , false ) ; } } }
Add MRUs to a PresetGroup sorting the paths by the timestamp
Add MRUs to a PresetGroup sorting the paths by the timestamp