From e107a105c4588e0b84b1d626a6bed2daf4490c58 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 28 Nov 2020 19:41:37 +0200 Subject: [PATCH] fixes after migration to ViewPager2 the activity is not the container of the view hierarchy, the view argument to onViewCreated() is --- .../ui/account_summary/AccountSummaryFragment.java | 4 ++-- .../ui/transaction_list/TransactionListFragment.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java index 9654f140..c4f863cb 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java @@ -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"); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java index 4ab877db..4495863c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java @@ -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); -- 2.39.2