From: Damyan Ivanov Date: Thu, 14 Mar 2019 21:26:41 +0000 (+0200) Subject: fix populating live account list when updating from JSON X-Git-Tag: v0.8~10 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=c040f83305fb25dfe9a7c088683926b7d101c373;p=mobile-ledger.git fix populating live account list when updating from JSON --- 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 c4f55d0e..e81a71c2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -396,14 +396,17 @@ public class RetrieveTransactionsTask ParsedLedgerAccount parsedAccount = parser.nextAccount(); if (parsedAccount == null) break; - LedgerAccount acc = new LedgerAccount(parsedAccount.getAname()); + LedgerAccount acc = profile.tryLoadAccount(db, parsedAccount.getAname()); + if (acc == null) acc = new LedgerAccount(parsedAccount.getAname()); + else acc.removeAmounts(); + profile.storeAccount(db, acc); for (ParsedBalance b : parsedAccount.getAebalance()) { profile.storeAccountValue(db, acc.getName(), b.getAcommodity(), b.getAquantity().asFloat()); } - accountList.add(acc); + if (acc.isVisible(accountList)) accountList.add(acc); } throwIfCancelled(); 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 0751d10a..f632bba9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -161,6 +161,6 @@ public class LedgerAccount { expanded = !expanded; } public void removeAmounts() { - amounts.clear(); + if (amounts != null) amounts.clear(); } }