+
+ if (sameProfileId) {
+ Logger.debug(TAG, String.format(Locale.ROOT, "Short-cut profile 'changed' to %d",
+ newProfile.getId()));
+ return;
+ }
+
+ mainModel.getAccountFilter()
+ .observe(this, this::onAccountFilterChanged);
+
+ mainModel.stopTransactionsRetrieval();
+ mainModel.clearTransactions();
+ }
+ private void onAccountFilterChanged(String accFilter) {
+ Logger.debug(TAG, "account filter changed, reloading transactions");
+// mainModel.scheduleTransactionListReload();
+ LiveData<List<TransactionWithAccounts>> transactions =
+ new MutableLiveData<>(new ArrayList<>());
+ 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 -> {
+ Logger.debug(TAG,
+ String.format(Locale.ROOT, "got transaction list from DB (%d transactions)",
+ list.size()));
+
+ if (converterThread != null)
+ converterThread.interrupt();
+ converterThread = new ConverterThread(mainModel, list, accFilter);
+ converterThread.start();
+ });