From: Damyan Ivanov Date: Sat, 24 Apr 2021 18:29:16 +0000 (+0000) Subject: store transaction list in a db transaction X-Git-Tag: v0.18.0~26 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=3f6686c63547ce6eaf6fe09b00a179ca8d49089c;p=mobile-ledger.git store transaction list in a db transaction otherwise each insert/update triggers a re-fetch of the while list, which is devastating for the UI and the battery --- diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java index 2c0995e1..715d6ea1 100644 --- a/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java +++ b/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java @@ -161,6 +161,7 @@ public abstract class TransactionDAO extends BaseDAO { return 0; return result.generation; } + @androidx.room.Transaction public void storeTransactionsSync(List list, long profileId) { long generation = getGenerationSync(profileId) + 1; @@ -179,7 +180,8 @@ public abstract class TransactionDAO extends BaseDAO { Logger.debug("Transaction", String.format(Locale.ROOT, "Purged %d transaction accounts", removed)); } - private void storeSync(TransactionWithAccounts rec) { + @androidx.room.Transaction + void storeSync(TransactionWithAccounts rec) { TransactionAccountDAO trAccDao = DB.get() .getTransactionAccountDAO();