Fix the last couple of sorting bugs (#77)

This fixes the following bugs:
- Sort category is forgotten after lock/unlock
- The sort mode is not respected for new entries

I got a little carried away while working on this patch and also included the
following other enhancements:
- Simplify the SortCategory, Theme and ViewMode enums
- Simplify usage of string resources
- Don't call notifyDataSetChanged and runLayoutAnimation unnecessarily
This commit is contained in:
Alexander Bakker 2019-05-15 21:29:45 +02:00 committed by Michael Schättgen
parent 0a8dd56306
commit 6d26d1beb0
12 changed files with 264 additions and 309 deletions

View file

@ -5,43 +5,13 @@ public enum Theme {
DARK,
AMOLED;
private static Theme[] _values;
static {
_values = values();
}
public static Theme fromInteger(int x) {
switch (x) {
case 0:
return LIGHT;
case 1:
return DARK;
case 2:
return AMOLED;
}
return null;
}
public static int getThemeNameResource(int x) {
switch (x) {
case 0:
return R.string.light_theme_title;
case 1:
return R.string.dark_theme_title;
case 2:
return R.string.amoled_theme_title;
}
return R.string.light_theme_title;
}
public static String[] getThemeNames() {
return new String[]{
"Light theme",
"Dark theme",
"Amoled theme"
};
}
public static int[] getThemeNameResources() {
return new int[] {
R.string.light_theme_title,
R.string.dark_theme_title,
R.string.amoled_theme_title
};
return _values[x];
}
}