X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=e5139b236168f57136cd59d05f72d04a238c1713;hb=08d7c928644409544a44a41d21e00d92daec7c8e;hp=a9db652ed0e0a0f0c8932ce81a9710c9f944da76;hpb=5249e165e131f912d4864ee2f4ce0263455023f2;p=mobile-ledger.git 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 a9db652e..e5139b23 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 @@ -95,6 +95,7 @@ public class MainActivity extends ProfileThemedActivity { private ProfilesRecyclerViewAdapter mProfileListAdapter; private int mCurrentPage; private String mAccountFilter; + private boolean mBackMeansToAccountList = false; @Override protected void onStart() { super.onStart(); @@ -168,6 +169,22 @@ public class MainActivity extends ProfileThemedActivity { fab.hide(); } + int old_index = -1; + int new_index = -1; + if (arg != null) { + MobileLedgerProfile old = (MobileLedgerProfile) arg; + old_index = Data.getProfileIndex(old); + new_index = Data.getProfileIndex(profile); + } + + if ((old_index != -1) && (new_index != -1)) { + mProfileListAdapter.notifyItemChanged(old_index); + mProfileListAdapter.notifyItemChanged(new_index); + } + else mProfileListAdapter.notifyDataSetChanged(); + + collapseProfileList(); + int newProfileTheme = profile.getThemeId(); if (newProfileTheme != Colors.profileThemeId) { Log.d("profiles", String.format("profile theme %d → %d", Colors.profileThemeId, @@ -175,6 +192,8 @@ public class MainActivity extends ProfileThemedActivity { profileThemeChanged(); Colors.profileThemeId = newProfileTheme; } + else + drawer.closeDrawers(); }); }); Data.profiles.addObserver((o, arg) -> { @@ -297,15 +316,17 @@ public class MainActivity extends ProfileThemedActivity { }); } private void updateLastUpdateDisplay() { + LinearLayout l = findViewById(R.id.transactions_last_update_layout); TextView v = findViewById(R.id.transactions_last_update); Date date = Data.lastUpdateDate.get(); if (date == null) { - v.setText(R.string.transaction_last_update_never); + l.setVisibility(View.INVISIBLE); Log.d("main", "no last update date :("); } else { final String text = DateFormat.getDateTimeInstance().format(date); v.setText(text); + l.setVisibility(View.VISIBLE); Log.d("main", String.format("Date formatted: %s", text)); } } @@ -421,6 +442,7 @@ public class MainActivity extends ProfileThemedActivity { // currentFragment = transactionListFragment; } public void showAccountTransactions(LedgerAccount account) { + mBackMeansToAccountList = true; showTransactionsFragment(account); } @Override @@ -430,10 +452,17 @@ public class MainActivity extends ProfileThemedActivity { drawer.closeDrawer(GravityCompat.START); } else { - Log.d("fragments", - String.format("manager stack: %d", fragmentManager.getBackStackEntryCount())); + if (mBackMeansToAccountList && (mViewPager.getCurrentItem() == 1)) { + TransactionListFragment.accountFilter.set(null); + showAccountSummaryFragment(); + mBackMeansToAccountList = false; + } + else { + Log.d("fragments", String.format("manager stack: %d", + fragmentManager.getBackStackEntryCount())); - super.onBackPressed(); + super.onBackPressed(); + } } } public void updateLastUpdateTextFromDB() {