]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java
fixes after migration to ViewPager2
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / ui / transaction_list / TransactionListFragment.java
index 9564cc8597317c79fa5bd378470c67eaf7ba9e0d..4495863cc6927dfdd3e02134c95552dd885c1f6d 100644 (file)
@@ -56,8 +56,6 @@ import java.util.Locale;
 import static android.content.Context.INPUT_METHOD_SERVICE;
 import static net.ktnx.mobileledger.utils.Logger.debug;
 
-// TODO: support transaction-level comment
-
 public class TransactionListFragment extends MobileLedgerListFragment
         implements DatePickerFragment.DatePickedListener {
     private MenuItem menuTransactionListFilter;
@@ -91,9 +89,9 @@ public class TransactionListFragment extends MobileLedgerListFragment
         debug("flow", "TransactionListFragment.onPause()");
     }
     @Override
-    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
+    public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
         debug("flow", "TransactionListFragment.onActivityCreated called");
-        super.onActivityCreated(savedInstanceState);
+        super.onViewCreated(view, savedInstanceState);
 
         Data.backgroundTasksRunning.observe(getViewLifecycleOwner(),
                 this::onBackgroundTaskRunningChanged);
@@ -102,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);
@@ -127,11 +125,11 @@ 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, view, position, id) -> {
+        accNameFilter.setOnItemClickListener((parent, v, position, id) -> {
 //                debug("tmp", "direct onItemClick");
             Cursor c = (Cursor) parent.getItemAtPosition(position);
             model.getAccountFilter()
@@ -148,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);