]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java
use getViewLifecycleOwner when observing LiveData from fragments
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionFragment.java
index 5cbbab71f5cb86c71ec23073437d2723e191972d..54c55fa54863be0e11c152340bd0bcc051fdead8 100644 (file)
@@ -98,7 +98,7 @@ public class NewTransactionFragment extends Fragment {
         listAdapter = new NewTransactionItemsAdapter(viewModel, mProfile);
         list.setAdapter(listAdapter);
         list.setLayoutManager(new LinearLayoutManager(activity));
-        Data.profile.observe(this, profile -> {
+        Data.profile.observe(getViewLifecycleOwner(), profile -> {
             mProfile = profile;
             listAdapter.setProfile(profile);
         });
@@ -142,7 +142,7 @@ public class NewTransactionFragment extends Fragment {
         }).attachToRecyclerView(list);
 
         viewModel.isSubmittable()
-                 .observe(this, isSubmittable -> {
+                 .observe(getViewLifecycleOwner(), isSubmittable -> {
                      if (isSubmittable) {
                          if (fab != null) {
                              fab.show();