mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Add SortCategory fixes and support for custom sorting
This commit is contained in:
parent
10b80442d0
commit
ecdadf5335
3 changed files with 15 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.beemdevelopment.aegis;
|
||||
|
||||
import com.beemdevelopment.aegis.helpers.comparators.AccountNameComparator;
|
||||
import com.beemdevelopment.aegis.helpers.comparators.IssuerNameComparator;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
@ -14,11 +15,9 @@ public enum SortCategory {
|
|||
public static Comparator getComparator(SortCategory sortCategory) {
|
||||
switch(sortCategory) {
|
||||
case ACCOUNT:
|
||||
return new IssuerNameComparator();
|
||||
case ACCOUNTREVERSED:
|
||||
return new IssuerNameComparator();
|
||||
return new AccountNameComparator();
|
||||
case ISSUER:
|
||||
return new IssuerNameComparator();
|
||||
case ISSUERREVERSED:
|
||||
return new IssuerNameComparator();
|
||||
case CUSTOM:
|
||||
|
@ -35,7 +34,7 @@ public enum SortCategory {
|
|||
return true;
|
||||
|
||||
default:
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,6 +265,13 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
private void setSortCategory(SortCategory sortCategory) {
|
||||
_sortCategory = sortCategory;
|
||||
|
||||
if(sortCategory == SortCategory.CUSTOM)
|
||||
{
|
||||
_entryListView.clearEntries();
|
||||
loadEntries();
|
||||
}
|
||||
|
||||
_entryListView.setSortCategory(sortCategory);
|
||||
}
|
||||
|
||||
|
@ -457,7 +464,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
case R.id.sort_custom:
|
||||
default:
|
||||
sortCategory = SortCategory.ACCOUNTREVERSED;
|
||||
sortCategory = SortCategory.CUSTOM;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,9 +155,8 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
}
|
||||
|
||||
public void setSortCategory(SortCategory sortCategory) {
|
||||
if (_sortCategory != sortCategory) {
|
||||
_sortCategory = sortCategory;
|
||||
Collections.sort(_shownEntries, new IssuerNameComparator());
|
||||
if (_sortCategory != sortCategory && sortCategory != SortCategory.CUSTOM) {
|
||||
Collections.sort(_shownEntries, SortCategory.getComparator(sortCategory));
|
||||
|
||||
if(SortCategory.isReversed(sortCategory))
|
||||
{
|
||||
|
@ -166,6 +165,8 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
_sortCategory = sortCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue