]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java
do not force transaction list reload upon main activity start
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / MainModel.java
index 039e24df6c45ed9495b09056efad4661debee203..9aafedd50e7e8e8b448cf1030cde8853ee9bde68 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<>();
@@ -133,7 +133,7 @@ public class MainModel extends ViewModel {
             String accNameFilter = model.getAccountFilter()
                                         .getValue();
 
-            TransactionAccumulator acc = new TransactionAccumulator(model);
+            TransactionAccumulator acc = new TransactionAccumulator(accNameFilter);
             for (LedgerTransaction tr : list) {
                 if (isInterrupted()) {
                     return;
@@ -143,10 +143,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");
         }
     }
 }