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;
}
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();
}
Aggregations