Better folder sort

pull/12/merge
M66B 6 years ago
parent f31644894e
commit cf73512897

@ -119,15 +119,17 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
Collections.sort(folders, new Comparator<TupleFolderEx>() { Collections.sort(folders, new Comparator<TupleFolderEx>() {
@Override @Override
public int compare(TupleFolderEx f1, TupleFolderEx f2) { public int compare(TupleFolderEx f1, TupleFolderEx f2) {
if (f1.accountName == null) int s = EntityFolder.isUser(f1.type).compareTo(EntityFolder.isUser(f2.type));
if (f2.accountName == null) if (s == 0) {
return 0; int a = collator.compare(
f1.accountName == null ? "" : f1.accountName,
f2.accountName == null ? "" : f2.accountName);
if (a == 0)
return collator.compare(f1.name, f2.name);
else else
return -1; return a;
else if (f2.accountName == null) } else
return 1; return s;
else
return collator.compare(f1.accountName, f2.accountName);
} }
}); });

@ -73,6 +73,10 @@ public class EntityFolder {
return (TYPE_OUTBOX.equals(type) || TYPE_DRAFTS.equals(type) || TYPE_SENT.equals(type)); return (TYPE_OUTBOX.equals(type) || TYPE_DRAFTS.equals(type) || TYPE_SENT.equals(type));
} }
static Boolean isUser(String type) {
return TYPE_USER.equals(type);
}
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
public Long id; public Long id;
public Long account; // Outbox = null public Long account; // Outbox = null

Loading…
Cancel
Save