]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fixes after migration to ViewPager2
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 28 Nov 2020 17:41:37 +0000 (19:41 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 20 Dec 2020 10:05:20 +0000 (10:05 +0000)
the activity is not the container of the view hierarchy, the view
argument to onViewCreated() is

app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java
app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java

index 9654f140f5739cdfe800e939e0eef4f535e24590..c4f863cb5de753350a8b492d0f8e9be8e83bcb42 100644 (file)
@@ -79,7 +79,7 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
         modelAdapter = new AccountSummaryAdapter(model);
         MainActivity mainActivity = getMainActivity();
 
-        root = mainActivity.findViewById(R.id.account_root);
+        root = view.findViewById(R.id.account_root);
         LinearLayoutManager llm = new LinearLayoutManager(mainActivity);
         llm.setOrientation(RecyclerView.VERTICAL);
         root.setLayoutManager(llm);
@@ -92,7 +92,7 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
 
         manageFabOnScroll();
 
-        refreshLayout = mainActivity.findViewById(R.id.account_swipe_refresh_layout);
+        refreshLayout = view.findViewById(R.id.account_swipe_refresh_layout);
         Colors.themeWatch.observe(getViewLifecycleOwner(), this::themeChanged);
         refreshLayout.setOnRefreshListener(() -> {
             debug("ui", "refreshing accounts via swipe");
index 4ab877dba7dbd4c158bfc7f00b445cd58941fa14..4495863cc6927dfdd3e02134c95552dd885c1f6d 100644 (file)
@@ -100,10 +100,10 @@ public class TransactionListFragment extends MobileLedgerListFragment
 
         model = new ViewModelProvider(requireActivity()).get(MainModel.class);
 
-        refreshLayout = mainActivity.findViewById(R.id.transaction_swipe);
+        refreshLayout = view.findViewById(R.id.transaction_swipe);
         if (refreshLayout == null)
             throw new RuntimeException("Can't get hold on the swipe layout");
-        root = mainActivity.findViewById(R.id.transaction_root);
+        root = view.findViewById(R.id.transaction_root);
         if (root == null)
             throw new RuntimeException("Can't get hold on the transaction value view");
         modelAdapter = new TransactionListAdapter(model);
@@ -125,8 +125,8 @@ public class TransactionListFragment extends MobileLedgerListFragment
 
         Colors.themeWatch.observe(getViewLifecycleOwner(), this::themeChanged);
 
-        vAccountFilter = mainActivity.findViewById(R.id.transaction_list_account_name_filter);
-        accNameFilter = mainActivity.findViewById(R.id.transaction_filter_account_name);
+        vAccountFilter = view.findViewById(R.id.transaction_list_account_name_filter);
+        accNameFilter = view.findViewById(R.id.transaction_filter_account_name);
 
         MLDB.hookAutocompletionAdapter(mainActivity, accNameFilter, "accounts", "name");
         accNameFilter.setOnItemClickListener((parent, v, position, id) -> {
@@ -146,8 +146,8 @@ public class TransactionListFragment extends MobileLedgerListFragment
         model.getDisplayedTransactions()
              .observe(getViewLifecycleOwner(), list -> modelAdapter.setTransactions(list));
 
-        mainActivity.findViewById(R.id.clearAccountNameFilter)
-                    .setOnClickListener(v -> {
+        view.findViewById(R.id.clearAccountNameFilter)
+            .setOnClickListener(v -> {
                         model.getAccountFilter()
                              .setValue(null);
                         vAccountFilter.setVisibility(View.GONE);