From: Damyan Ivanov Date: Sat, 24 Apr 2021 20:49:57 +0000 (+0300) Subject: restore account ordering by name X-Git-Tag: v0.18.0~25 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=49c93c4466da6754bfd63495cdff274935ca235e;hp=3f6686c63547ce6eaf6fe09b00a179ca8d49089c restore account ordering by name it was nice to use the ordering from hledger, but after the migration to room this worked only by chance - sqlite returned the rows in the order they were inserted. this means that any new accounts will end up at the bottom. this is the case when speculative transaction storage is active (coming soon) and the transaction has a new account. also, the conversion from db account objects to UI list relies on the ordering now. in a future version, the accounts table may store the hledger ordering in a new column, but this doesn't completely solve the problem when adding new accounts speculatively --- diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java index f37b940b..429e1643 100644 --- a/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java +++ b/app/src/main/java/net/ktnx/mobileledger/dao/AccountDAO.java @@ -75,11 +75,11 @@ public abstract class AccountDAO extends BaseDAO { @Delete public abstract void deleteSync(List items); - @Query("SELECT * FROM accounts WHERE profile_id=:profileId") + @Query("SELECT * FROM accounts WHERE profile_id=:profileId ORDER BY name") public abstract LiveData> getAll(long profileId); @Transaction - @Query("SELECT * FROM accounts WHERE profile_id = :profileId") + @Query("SELECT * FROM accounts WHERE profile_id = :profileId ORDER BY name") public abstract LiveData> getAllWithAmounts(long profileId); @Query("SELECT * FROM accounts WHERE id=:id")