X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2FMainModel.java;h=2355d2a833c2f5192d64887fac87162f39bc9bf2;hb=96c0c980b90119e043ee1d754cfcaa6115912321;hp=039e24df6c45ed9495b09056efad4661debee203;hpb=0b96f4968cd5c0b36474b94b94ec6dcf6699f60c;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java index 039e24df..2355d2a8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java @@ -41,7 +41,7 @@ import java.util.Locale; public class MainModel extends ViewModel { public final MutableLiveData foundTransactionItemIndex = new MutableLiveData<>(null); private final MutableLiveData updatingFlag = new MutableLiveData<>(false); - private final MutableLiveData accountFilter = new MutableLiveData<>(); + private final MutableLiveData accountFilter = new MutableLiveData<>(null); private final MutableLiveData> displayedTransactions = new MutableLiveData<>(new ArrayList<>()); private final MutableLiveData updateError = new MutableLiveData<>(); @@ -127,13 +127,12 @@ public class MainModel extends ViewModel { @Override public void run() { List 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"); } } }