+ mProfileListAdapter.notifyDataSetChanged();
+
+ if (haveProfile) {
+ if (newProfile.permitPosting()) {
+ b.toolbar.setSubtitle(null);
+ b.btnAddTransaction.show();
+ }
+ else {
+ b.toolbar.setSubtitle(R.string.profile_subtitle_read_only);
+ b.btnAddTransaction.hide();
+ }
+ }
+ else {
+ b.toolbar.setSubtitle(null);
+ b.btnAddTransaction.hide();
+ }
+
+ updateLastUpdateTextFromDB();
+
+ if (sameProfileId) {
+ Logger.debug(TAG, String.format(Locale.ROOT, "Short-cut profile 'changed' to %d",
+ newProfile.getId()));
+ return;
+ }
+
+ 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();