Search in sources :

Example 1 with SortHandler

use of com.amaze.filemanager.database.SortHandler in project AmazeFileManager by TeamAmaze.

the class GeneralDialogCreation method onSortTypeSelected.

private static void onSortTypeSelected(MainFragment m, SharedPreferences sharedPref, Set<String> onlyThisFloders, MaterialDialog dialog, boolean desc) {
    final int sortType = desc ? dialog.getSelectedIndex() + 4 : dialog.getSelectedIndex();
    SortHandler sortHandler = SortHandler.getInstance();
    if (onlyThisFloders.contains(m.getCurrentPath())) {
        Sort oldSort = sortHandler.findEntry(m.getCurrentPath());
        Sort newSort = new Sort(m.getCurrentPath(), sortType);
        if (oldSort == null) {
            sortHandler.addEntry(newSort);
        } else {
            sortHandler.updateEntry(oldSort, newSort);
        }
    } else {
        sortHandler.clear(m.getCurrentPath());
        sharedPref.edit().putString("sortby", String.valueOf(sortType)).apply();
    }
    sharedPref.edit().putStringSet(PREFERENCE_SORTBY_ONLY_THIS, onlyThisFloders).apply();
    m.updateList();
    dialog.dismiss();
}
Also used : Sort(com.amaze.filemanager.database.models.explorer.Sort) SortHandler(com.amaze.filemanager.database.SortHandler)

Aggregations

SortHandler (com.amaze.filemanager.database.SortHandler)1 Sort (com.amaze.filemanager.database.models.explorer.Sort)1