From 3f6686c63547ce6eaf6fe09b00a179ca8d49089c Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 24 Apr 2021 18:29:16 +0000 Subject: [PATCH] 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 --- .../main/java/net/ktnx/mobileledger/dao/TransactionDAO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(); -- 2.39.5