- @Override
- protected void onStart() {
- super.onStart();
- LinearLayout grp = drawer.findViewById(R.id.nav_actions);
- for (int i = 0; i < grp.getChildCount(); i++) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- grp.getChildAt(i).setBackgroundColor(
- getResources().getColor(R.color.drawer_background, getTheme()));
+ if (pageChangeCallback == null) {
+ pageChangeCallback = new ViewPager2.OnPageChangeCallback() {
+ @Override
+ public void onPageSelected(int position) {
+ mCurrentPage = position;
+ switch (position) {
+ case 0:
+ markDrawerItemCurrent(R.id.nav_account_summary);
+ break;
+ case 1:
+ markDrawerItemCurrent(R.id.nav_latest_transactions);
+ break;
+ default:
+ Log.e("MainActivity",
+ String.format("Unexpected page index %d", position));
+ }
+
+ super.onPageSelected(position);
+ }
+ };
+ b.mainPager.registerOnPageChangeCallback(pageChangeCallback);
+ }
+
+ mCurrentPage = 0;
+ if (savedInstanceState != null) {
+ int currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE, -1);
+ if (currentPage != -1) {
+ mCurrentPage = currentPage;
+ }
+ mainModel.getAccountFilter()
+ .setValue(savedInstanceState.getString(STATE_ACC_FILTER, null));
+ }
+
+ b.btnNoProfilesAdd.setOnClickListener(
+ v -> MobileLedgerProfile.startEditProfileActivity(this, null));
+
+ b.btnAddTransaction.setOnClickListener(this::fabNewTransactionClicked);
+
+ b.navNewProfileButton.setOnClickListener(
+ v -> MobileLedgerProfile.startEditProfileActivity(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));
+ }