Simplify account ordering

This commit is contained in:
M66B 2019-04-27 21:34:53 +02:00
parent 065f7caac9
commit 58b8c071be
2 changed files with 4 additions and 14 deletions

View File

@ -29,10 +29,12 @@ import java.util.List;
@Dao
public interface DaoAccount {
@Query("SELECT * FROM account")
@Query("SELECT * FROM account" +
" ORDER BY `order`, `primary` DESC, name COLLATE NOCASE")
List<EntityAccount> getAccounts();
@Query("SELECT * FROM account WHERE synchronize")
@Query("SELECT * FROM account WHERE synchronize" +
" ORDER BY `order`, `primary` DESC, name COLLATE NOCASE")
List<EntityAccount> getSynchronizingAccounts();
@Query("SELECT * FROM account WHERE tbd = 1")

View File

@ -1159,18 +1159,6 @@ public class FragmentMessages extends FragmentBase {
result.accounts = db.account().getSynchronizingAccounts();
final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
Collections.sort(result.accounts, new Comparator<EntityAccount>() {
@Override
public int compare(EntityAccount a1, EntityAccount a2) {
int p = -a1.primary.compareTo(a2.primary);
if (p != 0)
return p;
return collator.compare(a1.name, a2.name);
}
});
for (EntityAccount account : result.accounts) {
List<EntityFolder> targets = new ArrayList<>();
List<EntityFolder> folders = db.folder().getFolders(account.id);