From c040f83305fb25dfe9a7c088683926b7d101c373 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 14 Mar 2019 23:26:41 +0200 Subject: [PATCH] fix populating live account list when updating from JSON --- .../ktnx/mobileledger/async/RetrieveTransactionsTask.java | 7 +++++-- .../java/net/ktnx/mobileledger/model/LedgerAccount.java | 2 +- 2 files changed, 6 insertions(+), 3 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 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(); } } -- 2.39.5