]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java
use getViewLifecycleOwner when observing LiveData from fragments
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / account_summary / AccountSummaryFragment.java
index 5796b3365e64f0cfb79a95537ae66ae9209f7a62..6482dfd1397389d5c4eb4a75770c960a5e1d88fc 100644 (file)
@@ -42,7 +42,6 @@ import androidx.recyclerview.widget.RecyclerView;
 import static net.ktnx.mobileledger.utils.Logger.debug;
 
 public class AccountSummaryFragment extends MobileLedgerListFragment {
-
     public AccountSummaryAdapter modelAdapter;
     /*
         private MenuItem mShowOnlyStarred;
@@ -55,7 +54,8 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
         debug("flow", "AccountSummaryFragment.onCreate()");
         setHasOptionsMenu(true);
 
-        Data.backgroundTasksRunning.observe(this, this::onBackgroundTaskRunningChanged);
+        Data.backgroundTasksRunning.observe(this.getViewLifecycleOwner(),
+                this::onBackgroundTaskRunningChanged);
     }
     public void onAttach(@NotNull Context context) {
         super.onAttach(context);
@@ -94,10 +94,10 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
         manageFabOnScroll();
 
         swiper = mActivity.findViewById(R.id.account_swiper);
-        Colors.themeWatch.observe(this, this::themeChanged);
+        Colors.themeWatch.observe(getViewLifecycleOwner(), this::themeChanged);
         swiper.setOnRefreshListener(() -> {
             debug("ui", "refreshing accounts via swipe");
-            mActivity.scheduleTransactionListRetrieval();
+            Data.scheduleTransactionListRetrieval(mActivity);
         });
 
         Data.accounts.addObserver(