X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2FMainModel.java;h=6d640d622d5bca660f578cd14b0b8e212f67fd34;hp=5bc2554c4ff9b4f0db96824a6d017aca01891e00;hb=2d85826653a8ba3e619afc83c5c91216a7fdb0b6;hpb=1eb1a8f63e0536b089a624994c2bcf5f0b462580 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 5bc2554c..6d640d62 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java @@ -32,6 +32,7 @@ import net.ktnx.mobileledger.App; import net.ktnx.mobileledger.async.RetrieveTransactionsTask; import net.ktnx.mobileledger.async.TransactionAccumulator; import net.ktnx.mobileledger.async.UpdateTransactionsTask; +import net.ktnx.mobileledger.model.AccountListItem; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.LedgerAccount; import net.ktnx.mobileledger.model.LedgerTransaction; @@ -55,17 +56,17 @@ import static net.ktnx.mobileledger.utils.Logger.debug; public class MainModel extends ViewModel { public final MutableLiveData foundTransactionItemIndex = new MutableLiveData<>(null); - public final MutableLiveData lastUpdateDate = new MutableLiveData<>(null); private final MutableLiveData updatingFlag = new MutableLiveData<>(false); private final MutableLiveData accountFilter = new MutableLiveData<>(); private final MutableLiveData> displayedTransactions = new MutableLiveData<>(new ArrayList<>()); - private final MutableLiveData> displayedAccounts = new MutableLiveData<>(); + private final MutableLiveData> displayedAccounts = + new MutableLiveData<>(); private final Locker accountsLocker = new Locker(); private final MutableLiveData updateError = new MutableLiveData<>(); + private final Map accountMap = new HashMap<>(); private MobileLedgerProfile profile; private List allAccounts = new ArrayList<>(); - private final Map accountMap = new HashMap<>(); private SimpleDate firstTransactionDate; private SimpleDate lastTransactionDate; transient private RetrieveTransactionsTask retrieveTransactionsTask; @@ -127,7 +128,7 @@ public class MainModel extends ViewModel { debug("db", "Updating transaction value stamp"); Date now = new Date(); profile.setLongOption(MLDB.OPT_LAST_SCRAPE, now.getTime()); - lastUpdateDate.postValue(now); + Data.lastUpdateLiveData.postValue(now); } public void scheduleTransactionListReload() { UpdateTransactionsTask task = new UpdateTransactionsTask(); @@ -209,7 +210,7 @@ public class MainModel extends ViewModel { updateAccountsMap(allAccounts); } } - public LiveData> getDisplayedAccounts() { + public LiveData> getDisplayedAccounts() { return displayedAccounts; } synchronized public void scheduleAccountListReload() { @@ -355,18 +356,17 @@ public class MainModel extends ViewModel { } @Override public void run() { - List newDisplayed = new ArrayList<>(); + 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 accounts)", list.size())); + newDisplayed.add(new AccountListItem()); // header for (LedgerAccount a : list) { - if (isInterrupted()) { + if (isInterrupted()) return; - } - if (a.isVisible()) { - newDisplayed.add(a); - } + if (a.isVisible()) + newDisplayed.add(new AccountListItem(a)); } if (!isInterrupted()) { model.displayedAccounts.postValue(newDisplayed);