Add way to check for reversed sort categories

This commit is contained in:
Michael Schättgen 2019-03-31 20:14:11 +02:00
parent 09fe550a28
commit 62025d1053
2 changed files with 14 additions and 3 deletions

View file

@ -26,4 +26,16 @@ public enum SortCategory {
}
return null;
}
public static boolean isReversed(SortCategory sortCategory) {
switch(sortCategory)
{
case ACCOUNTREVERSED:
case ISSUERREVERSED:
return true;
default:
return true;
}
}
}

View file

@ -155,12 +155,11 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
}
public void setSortCategory(SortCategory sortCategory) {
if (_sortCategory != sortCategory)
{
if (_sortCategory != sortCategory) {
_sortCategory = sortCategory;
Collections.sort(_shownEntries, new IssuerNameComparator());
if(sortCategory == SortCategory.ACCOUNTREVERSED || sortCategory == SortCategory.ISSUERREVERSED)
if(SortCategory.isReversed(sortCategory))
{
Collections.reverse(_shownEntries);
}