From: Damyan Ivanov Date: Sat, 28 Nov 2020 17:41:37 +0000 (+0200) Subject: fixes after migration to ViewPager2 X-Git-Tag: v0.16.0~24 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=e107a105c4588e0b84b1d626a6bed2daf4490c58;p=mobile-ledger.git fixes after migration to ViewPager2 the activity is not the container of the view hierarchy, the view argument to onViewCreated() is --- 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);