+ b.navNewProfileButton.setOnClickListener(v -> ProfileDetailActivity.start(this, null));
+
+ b.transactionListCancelDownload.setOnClickListener(this::onStopTransactionRefreshClick);
+
+ if (mProfileListAdapter == null)
+ mProfileListAdapter = new ProfilesRecyclerViewAdapter();
+ b.navProfileList.setAdapter(mProfileListAdapter);
+
+ mProfileListAdapter.editingProfiles.observe(this, newValue -> {
+ if (newValue) {
+ b.navProfilesStartEdit.setVisibility(View.GONE);
+ b.navProfilesCancelEdit.setVisibility(View.VISIBLE);
+ b.navNewProfileButton.setVisibility(View.VISIBLE);
+ if (b.drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ b.navProfilesStartEdit.startAnimation(
+ AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_out));
+ b.navProfilesCancelEdit.startAnimation(
+ AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_in));
+ b.navNewProfileButton.startAnimation(
+ AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_in));
+ }
+ }
+ else {
+ b.navProfilesCancelEdit.setVisibility(View.GONE);
+ b.navProfilesStartEdit.setVisibility(View.VISIBLE);
+ b.navNewProfileButton.setVisibility(View.GONE);
+ if (b.drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ b.navProfilesCancelEdit.startAnimation(
+ AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_out));
+ b.navProfilesStartEdit.startAnimation(
+ AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_in));
+ b.navNewProfileButton.startAnimation(
+ AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_out));
+ }
+ }
+
+ mProfileListAdapter.notifyDataSetChanged();
+ });
+
+ fabManager = new FabManager(b.btnAddTransaction);
+
+ LinearLayoutManager llm = new LinearLayoutManager(this);
+
+ llm.setOrientation(RecyclerView.VERTICAL);
+ b.navProfileList.setLayoutManager(llm);
+
+ b.navProfilesStartEdit.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
+ b.navProfilesCancelEdit.setOnClickListener(
+ (v) -> mProfileListAdapter.flipEditingProfiles());
+ b.navProfileListHeadButtons.setOnClickListener(
+ (v) -> mProfileListAdapter.flipEditingProfiles());
+ if (drawerListener == null) {
+ drawerListener = new DrawerLayout.SimpleDrawerListener() {
+ @Override
+ public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
+ if (slideOffset > 0.2)
+ fabManager.hideFab();
+ }
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ mProfileListAdapter.setAnimationsEnabled(false);
+ mProfileListAdapter.editingProfiles.setValue(false);
+ Data.drawerOpen.setValue(false);
+ fabShouldShow();
+ }
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ mProfileListAdapter.setAnimationsEnabled(true);
+ Data.drawerOpen.setValue(true);
+ fabManager.hideFab();
+ }
+ };
+ b.drawerLayout.addDrawerListener(drawerListener);
+ }
+
+ Data.drawerOpen.observe(this, open -> {
+ if (open)
+ b.drawerLayout.open();
+ else
+ b.drawerLayout.close();
+ });
+
+ mainModel.getUpdateError()
+ .observe(this, (error) -> {
+ if (error == null)
+ return;
+
+ Snackbar.make(b.mainPager, error, Snackbar.LENGTH_INDEFINITE)
+ .show();
+ mainModel.clearUpdateError();
+ });
+ Data.locale.observe(this, l -> refreshLastUpdateInfo());
+ Data.lastUpdateDate.observe(this, date -> refreshLastUpdateInfo());
+ Data.lastUpdateTransactionCount.observe(this, date -> refreshLastUpdateInfo());
+ Data.lastUpdateAccountCount.observe(this, date -> refreshLastUpdateInfo());
+ b.navAccountSummary.setOnClickListener(this::onAccountSummaryClicked);
+ b.navLatestTransactions.setOnClickListener(this::onLatestTransactionsClicked);
+ b.navPatterns.setOnClickListener(this::onPatternsClick);