]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix populating live account list when updating from JSON
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 14 Mar 2019 21:26:41 +0000 (23:26 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 15 Mar 2019 02:57:42 +0000 (04:57 +0200)
app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java

index c4f55d0e7e6114caf66151ca71f276981eb31d16..e81a71c2c87b098cb6bcaa072790f191a3493e0f 100644 (file)
@@ -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();
 
index 0751d10ac4aec966b6d289f4fccdcc78f43fa9b3..f632bba94311d97485e6f98584776c9176095bd6 100644 (file)
@@ -161,6 +161,6 @@ public class LedgerAccount {
         expanded = !expanded;
     }
     public void removeAmounts() {
-        amounts.clear();
+        if (amounts != null) amounts.clear();
     }
 }