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;
|
package com.beemdevelopment.aegis;
|
||||||
|
|
||||||
|
import com.beemdevelopment.aegis.helpers.comparators.AccountNameComparator;
|
||||||
import com.beemdevelopment.aegis.helpers.comparators.IssuerNameComparator;
|
import com.beemdevelopment.aegis.helpers.comparators.IssuerNameComparator;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -14,11 +15,9 @@ public enum SortCategory {
|
||||||
public static Comparator getComparator(SortCategory sortCategory) {
|
public static Comparator getComparator(SortCategory sortCategory) {
|
||||||
switch(sortCategory) {
|
switch(sortCategory) {
|
||||||
case ACCOUNT:
|
case ACCOUNT:
|
||||||
return new IssuerNameComparator();
|
|
||||||
case ACCOUNTREVERSED:
|
case ACCOUNTREVERSED:
|
||||||
return new IssuerNameComparator();
|
return new AccountNameComparator();
|
||||||
case ISSUER:
|
case ISSUER:
|
||||||
return new IssuerNameComparator();
|
|
||||||
case ISSUERREVERSED:
|
case ISSUERREVERSED:
|
||||||
return new IssuerNameComparator();
|
return new IssuerNameComparator();
|
||||||
case CUSTOM:
|
case CUSTOM:
|
||||||
|
@ -35,7 +34,7 @@ public enum SortCategory {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,13 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
private void setSortCategory(SortCategory sortCategory) {
|
private void setSortCategory(SortCategory sortCategory) {
|
||||||
_sortCategory = sortCategory;
|
_sortCategory = sortCategory;
|
||||||
|
|
||||||
|
if(sortCategory == SortCategory.CUSTOM)
|
||||||
|
{
|
||||||
|
_entryListView.clearEntries();
|
||||||
|
loadEntries();
|
||||||
|
}
|
||||||
|
|
||||||
_entryListView.setSortCategory(sortCategory);
|
_entryListView.setSortCategory(sortCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +464,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
case R.id.sort_custom:
|
case R.id.sort_custom:
|
||||||
default:
|
default:
|
||||||
sortCategory = SortCategory.ACCOUNTREVERSED;
|
sortCategory = SortCategory.CUSTOM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,9 +155,8 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSortCategory(SortCategory sortCategory) {
|
public void setSortCategory(SortCategory sortCategory) {
|
||||||
if (_sortCategory != sortCategory) {
|
if (_sortCategory != sortCategory && sortCategory != SortCategory.CUSTOM) {
|
||||||
_sortCategory = sortCategory;
|
Collections.sort(_shownEntries, SortCategory.getComparator(sortCategory));
|
||||||
Collections.sort(_shownEntries, new IssuerNameComparator());
|
|
||||||
|
|
||||||
if(SortCategory.isReversed(sortCategory))
|
if(SortCategory.isReversed(sortCategory))
|
||||||
{
|
{
|
||||||
|
@ -166,6 +165,8 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sortCategory = sortCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue