]> git.ktnx.net Git - mobile-ledger.git/commitdiff
update the in-memory account list after parsing the JSON account list
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 7 Mar 2019 04:14:16 +0000 (06:14 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 7 Mar 2019 04:14:16 +0000 (06:14 +0200)
similar to what the legacy code does already

app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java

index 965c1f982fc98db94458dfb1109d9e4eabd07c67..dcc91b2f27ff2a7cb2aa5433afee4970741522df 100644 (file)
@@ -372,6 +372,7 @@ public class RetrieveTransactionsTask
                     profile.markAccountsAsNotPresent(db);
 
                     AccountListParser parser = new AccountListParser(resp);
+                    ArrayList<LedgerAccount> accountList = new ArrayList<>();
 
                     while (true) {
                         throwIfCancelled();
@@ -384,12 +385,15 @@ public class RetrieveTransactionsTask
                             profile.storeAccountValue(acc.getName(), b.getAcommodity(),
                                     b.getAquantity().asFloat());
                         }
+
+                        accountList.add(acc);
                     }
                     throwIfCancelled();
 
                     profile.deleteNotPresentAccounts(db);
                     throwIfCancelled();
                     db.setTransactionSuccessful();
+                    Data.accounts.set(accountList);
                 }
                 finally {
                     db.endTransaction();