From 010406b05a5a4f8447af34187afef8c1e78a4552 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 14 Mar 2019 22:05:50 +0200 Subject: [PATCH] fix duplication af account amounts on refresh --- .../ktnx/mobileledger/async/RetrieveTransactionsTask.java | 5 +++-- .../main/java/net/ktnx/mobileledger/model/LedgerAccount.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index dfb1f745..8f1a764b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -170,9 +170,10 @@ public class RetrieveTransactionsTask L(String.format("found account: %s", acct_name)); lastAccount = profile.tryLoadAccount(db, acct_name); - if (lastAccount == null) { + if (lastAccount == null) lastAccount = new LedgerAccount(acct_name); - } + else + lastAccount.removeAmounts(); profile.storeAccount(db, lastAccount); // make sure the parent account(s) are present, diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java index 93c78de2..0751d10a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -160,4 +160,7 @@ public class LedgerAccount { public void toggleExpanded() { expanded = !expanded; } + public void removeAmounts() { + amounts.clear(); + } } -- 2.39.5