Data.backgroundTaskCount.addObserver(backgroundTaskCountObserver = new Observer() {
@Override
public void update(Observable o, Object arg) {
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- int cnt = Data.backgroundTaskCount.get();
- Log.d("trl", String.format("background task count changed to %d", cnt));
- swiper.setRefreshing(cnt > 0);
- }
+ mActivity.runOnUiThread(() -> {
+ int cnt = Data.backgroundTaskCount.get();
+ Log.d("trl", String.format("background task count changed to %d", cnt));
+ swiper.setRefreshing(cnt > 0);
});
}
});
Log.d("flow", "TransactionListFragment.onActivityCreated called");
super.onActivityCreated(savedInstanceState);
- 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);
modelAdapter = new TransactionListAdapter();
modelAdapter.setBoldAccountName(mShowOnlyAccountName);
+ root.setAdapter(modelAdapter);
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();
- }
+ if (dy < 0) fab.show();
+ if (dy > 0) fab.hide();
}
});
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("tmp", "direct onItemClick");
- ((TransactionListViewModel) model).scheduleTransactionListReload(mActivity);
+ TransactionListViewModel.scheduleTransactionListReload(mActivity);
MatrixCursor mc = (MatrixCursor) parent.getItemAtPosition(position);
modelAdapter.setBoldAccountName(mc.getString(1));
modelAdapter.notifyDataSetChanged();
Data.transactions.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- modelAdapter.notifyDataSetChanged();
- }
- });
+ mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged());
}
});