+
+ mActivity.markDrawerItemCurrent(R.id.nav_latest_transactions);
+
+ 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 list view");
+ progressBar = mActivity.findViewById(R.id.transaction_list_progress_bar);
+ if (progressBar == null)
+ throw new RuntimeException("Can't get hold on the transaction list progress bar");
+ progressLayout = mActivity.findViewById(R.id.transaction_progress_layout);
+ if (progressLayout == null) throw new RuntimeException(
+ "Can't get hold on the transaction list progress bar layout");
+ model = ViewModelProviders.of(this).get(TransactionListViewModel.class);
+ modelAdapter = new TransactionListAdapter(model);
+
+ modelAdapter.setBoldAccountName(mShowOnlyAccountName);
+
+ FloatingActionButton fab = mActivity.findViewById(R.id.btn_add_transaction);
+
+ RecyclerView root = mActivity.findViewById(R.id.transaction_root);
+ root.setAdapter(modelAdapter);
+
+ fab.show();
+ root.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ if (fab != null) {
+ if (dy < 0) fab.show();
+ if (dy > 0) fab.hide();
+ }
+ }
+ });
+
+ LinearLayoutManager llm = new LinearLayoutManager(mActivity);
+
+ llm.setOrientation(LinearLayoutManager.VERTICAL);
+ root.setLayoutManager(llm);
+
+ swiper.setOnRefreshListener(() -> {
+ Log.d("ui", "refreshing transactions via swipe");
+ update_transactions();
+ });
+
+ swiper.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent);
+
+ vAccountFilter = mActivity.findViewById(R.id.transaction_list_account_name_filter);
+ accNameFilter = mActivity.findViewById(R.id.transaction_filter_account_name);
+ bTransactionListCancelDownload =
+ mActivity.findViewById(R.id.transaction_list_cancel_download);
+
+ TransactionListFragment me = this;
+ MLDB.hook_autocompletion_adapter(mActivity, accNameFilter, "accounts", "name");
+ accNameFilter.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ Log.d("tmp", "direct onItemClick");
+ model.reloadTransactions(me);
+ MatrixCursor mc = (MatrixCursor) parent.getItemAtPosition(position);
+ modelAdapter.setBoldAccountName(mc.getString(1));
+ modelAdapter.notifyDataSetChanged();
+ Globals.hideSoftKeyboard(mActivity);
+ }
+ });
+
+ if (mShowOnlyAccountName != null) {
+ accNameFilter.setText(mShowOnlyAccountName, false);
+ onShowFilterClick(null);
+ Log.d("flow", String.format("Account filter set to '%s'", mShowOnlyAccountName));
+ }
+
+ model.reloadTransactions(this);
+ }
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.transaction_list, menu);
+
+ menuTransactionListFilter = menu.findItem(R.id.menu_transaction_list_filter);
+ if ((menuTransactionListFilter == null)) throw new AssertionError();
+
+ if (mShowOnlyAccountName != null) {
+ menuTransactionListFilter.setVisible(false);
+ }
+
+ super.onCreateOptionsMenu(menu, inflater);