From: Damyan Ivanov Date: Sat, 1 Jun 2019 16:49:31 +0000 (+0300) Subject: replace in-activity copy of account name filter value with the global item in Data X-Git-Tag: v0.10.1~5 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=52aac35d8e7fd33dea55aa29f5b19ca6c39aaaa8;p=mobile-ledger.git replace in-activity copy of account name filter value with the global item in Data also solves filter disappearing when switching back to the app --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index afa9c71e..bd28ab29 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -94,7 +94,6 @@ public class MainActivity extends ProfileThemedActivity { private FloatingActionButton fab; private ProfilesRecyclerViewAdapter mProfileListAdapter; private int mCurrentPage; - private String mAccountFilter; private boolean mBackMeansToAccountList = false; private Toolbar mToolbar; private DrawerLayout.SimpleDrawerListener drawerListener; @@ -105,19 +104,14 @@ public class MainActivity extends ProfileThemedActivity { protected void onStart() { super.onStart(); - debug("flow", String.format(Locale.ENGLISH, - "MainActivity.onStart(), currentPage is %d, accountFilter is %s", mCurrentPage, - (mAccountFilter == null) ? "" : mAccountFilter)); mViewPager.setCurrentItem(mCurrentPage, false); - if (mAccountFilter != null) showTransactionsFragment(mAccountFilter); - else Data.accountFilter.setValue(null); - } @Override protected void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_CURRENT_PAGE, mViewPager.getCurrentItem()); - if (mAccountFilter != null) outState.putString(STATE_ACC_FILTER, mAccountFilter); + if (Data.accountFilter.getValue() != null) + outState.putString(STATE_ACC_FILTER, Data.accountFilter.getValue()); } @Override protected void onDestroy() { @@ -225,9 +219,8 @@ public class MainActivity extends ProfileThemedActivity { if (currentPage != -1) { mCurrentPage = currentPage; } - mAccountFilter = savedInstanceState.getString(STATE_ACC_FILTER, null); + Data.accountFilter.setValue(savedInstanceState.getString(STATE_ACC_FILTER, null)); } - else mAccountFilter = null; Data.lastUpdateDate.observe(this, this::updateLastUpdateDisplay);