+
+ swiper = mActivity.findViewById(R.id.transaction_swipe);
+ if (swiper == null) throw new RuntimeException("Can't get hold on the swipe layout");
+ root = mActivity.findViewById(R.id.transaction_root);
+ if (root == null)
+ throw new RuntimeException("Can't get hold on the transaction value view");
+ modelAdapter = new TransactionListAdapter();
+ root.setAdapter(modelAdapter);
+
+ mActivity.fabShouldShow();
+
+ manageFabOnScroll();
+
+ LinearLayoutManager llm = new LinearLayoutManager(mActivity);
+
+ llm.setOrientation(RecyclerView.VERTICAL);
+ root.setLayoutManager(llm);
+
+ swiper.setOnRefreshListener(() -> {
+ debug("ui", "refreshing transactions via swipe");
+ Data.scheduleTransactionListRetrieval(mActivity);
+ });
+
+ Colors.themeWatch.observe(this, this::themeChanged);
+
+ vAccountFilter = mActivity.findViewById(R.id.transaction_list_account_name_filter);
+ accNameFilter = mActivity.findViewById(R.id.transaction_filter_account_name);
+
+ MLDB.hookAutocompletionAdapter(mActivity, accNameFilter, "accounts", "name", true);
+ accNameFilter.setOnItemClickListener((parent, view, position, id) -> {
+// debug("tmp", "direct onItemClick");
+ MatrixCursor mc = (MatrixCursor) parent.getItemAtPosition(position);
+ Data.accountFilter.setValue(mc.getString(1));
+ Globals.hideSoftKeyboard(mActivity);
+ });
+
+ Data.accountFilter.observe(this, this::onAccountNameFilterChanged);
+
+ TransactionListViewModel.updating.addObserver(
+ (o, arg) -> swiper.setRefreshing(TransactionListViewModel.updating.get()));
+ TransactionListViewModel.updateError.addObserver((o, arg) -> {
+ String err = TransactionListViewModel.updateError.get();
+ if (err == null) return;
+
+ Toast.makeText(mActivity, err, Toast.LENGTH_SHORT).show();
+ TransactionListViewModel.updateError.set(null);
+ });
+ Data.transactions.addObserver(
+ (o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged()));
+
+ mActivity.findViewById(R.id.clearAccountNameFilter).setOnClickListener(v -> {
+ Data.accountFilter.setValue(null);
+ vAccountFilter.setVisibility(View.GONE);
+ menuTransactionListFilter.setVisible(true);
+ Globals.hideSoftKeyboard(mActivity);
+ });