]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java
Room-based profile management
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / account_summary / AccountSummaryFragment.java
index 9d9c2c64bc4c1689facb75b83775811c62d67663..d5964e4b3ce53002f50a1224391ca862bf500433 100644 (file)
@@ -34,6 +34,7 @@ import androidx.recyclerview.widget.RecyclerView;
 import net.ktnx.mobileledger.R;
 import net.ktnx.mobileledger.db.AccountWithAmounts;
 import net.ktnx.mobileledger.db.DB;
+import net.ktnx.mobileledger.db.Profile;
 import net.ktnx.mobileledger.model.AccountListItem;
 import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.LedgerAccount;
@@ -104,10 +105,12 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
             model.scheduleTransactionListRetrieval();
         });
 
+        Data.observeProfile(this, this::onProfileChanged);
+    }
+    private void onProfileChanged(Profile profile) {
         DB.get()
           .getAccountDAO()
-          .getAllWithAmounts(Data.getProfile()
-                                 .getId())
+          .getAllWithAmounts(profile.getId())
           .observe(getViewLifecycleOwner(), list -> AsyncTask.execute(() -> {
               List<AccountListItem> adapterList = new ArrayList<>();
               adapterList.add(new AccountListItem.Header(Data.lastAccountsUpdateText));