+ mainModel.getAccountFilter()
+ .observe(this, accFilter -> {
+ Logger.debug(TAG, "account filter changed, reloading transactions");
+// mainModel.scheduleTransactionListReload();
+ LiveData<List<TransactionWithAccounts>> transactions =
+ new MutableLiveData<>(new ArrayList<TransactionWithAccounts>());
+ if (profile != null) {
+ if (accFilter == null || accFilter.isEmpty()) {
+ transactions = DB.get()
+ .getTransactionDAO()
+ .getAllWithAccounts(profile.getId());
+ }
+ else {
+ transactions = DB.get()
+ .getTransactionDAO()
+ .getAllWithAccountsFiltered(profile.getId(),
+ accFilter);
+ }
+ }
+
+ transactions.observe(this, list -> {
+ TransactionAccumulator accumulator = new TransactionAccumulator(accFilter);
+
+ for (TransactionWithAccounts tr : list)
+ accumulator.put(new LedgerTransaction(tr));
+
+ accumulator.publishResults(mainModel);
+ });
+ });
+
+ mainModel.stopTransactionsRetrieval();
+ mainModel.clearTransactions();
+ }
+ private void profileThemeChanged() {
+ // un-hook all observed LiveData
+ Data.removeProfileObservers(this);
+ Data.profiles.removeObservers(this);
+ Data.lastUpdateTransactionCount.removeObservers(this);
+ Data.lastUpdateAccountCount.removeObservers(this);
+ Data.lastUpdateDate.removeObservers(this);
+
+ Logger.debug(TAG, "profileThemeChanged(): recreating activity");
+ recreate();