Search in sources :

Example 1 with Sort

use of com.amaze.filemanager.database.models.explorer.Sort in project AmazeFileManager by TeamAmaze.

the class SortHandler method getSortType.

public static int getSortType(Context context, String path) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    final Set<String> onlyThisFloders = sharedPref.getStringSet(PREFERENCE_SORTBY_ONLY_THIS, new HashSet<>());
    final boolean onlyThis = onlyThisFloders.contains(path);
    final int globalSortby = Integer.parseInt(sharedPref.getString("sortby", "0"));
    if (!onlyThis) {
        return globalSortby;
    }
    Sort sort = SortHandler.getInstance().findEntry(path);
    if (sort == null) {
        return globalSortby;
    }
    return sort.type;
}
Also used : SharedPreferences(android.content.SharedPreferences) Sort(com.amaze.filemanager.database.models.explorer.Sort)

Example 2 with Sort

use of com.amaze.filemanager.database.models.explorer.Sort 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

Sort (com.amaze.filemanager.database.models.explorer.Sort)2 SharedPreferences (android.content.SharedPreferences)1 SortHandler (com.amaze.filemanager.database.SortHandler)1