]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java
debug refinements
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / MainModel.java
index 039e24df6c45ed9495b09056efad4661debee203..2355d2a833c2f5192d64887fac87162f39bc9bf2 100644 (file)
@@ -41,7 +41,7 @@ import java.util.Locale;
 public class MainModel extends ViewModel {
     public final MutableLiveData<Integer> foundTransactionItemIndex = new MutableLiveData<>(null);
     private final MutableLiveData<Boolean> updatingFlag = new MutableLiveData<>(false);
-    private final MutableLiveData<String> accountFilter = new MutableLiveData<>();
+    private final MutableLiveData<String> accountFilter = new MutableLiveData<>(null);
     private final MutableLiveData<List<TransactionListItem>> displayedTransactions =
             new MutableLiveData<>(new ArrayList<>());
     private final MutableLiveData<String> updateError = new MutableLiveData<>();
@@ -127,13 +127,12 @@ public class MainModel extends ViewModel {
         @Override
         public void run() {
             List<LedgerAccount> newDisplayed = new ArrayList<>();
-            Logger.debug("dFilter", "waiting for synchronized block");
             Logger.debug("dFilter", String.format(Locale.US,
                     "entered synchronized block (about to examine %d transactions)", list.size()));
             String accNameFilter = model.getAccountFilter()
                                         .getValue();
 
-            TransactionAccumulator acc = new TransactionAccumulator(model);
+            TransactionAccumulator acc = new TransactionAccumulator(accNameFilter);
             for (LedgerTransaction tr : list) {
                 if (isInterrupted()) {
                     return;
@@ -143,10 +142,12 @@ public class MainModel extends ViewModel {
                     acc.put(tr, tr.getDate());
                 }
             }
-            if (!isInterrupted()) {
-                acc.done();
-            }
-            Logger.debug("dFilter", "left synchronized block");
+
+            if (isInterrupted())
+                return;
+
+            acc.publishResults(model);
+            Logger.debug("dFilter", "transaction list updated");
         }
     }
 }