From 1e2d83acbd8eb0c9b96d6b1e49dd326ee0a7befc Mon Sep 17 00:00:00 2001 From: JeanGarf Date: Mon, 15 Jun 2020 02:42:10 +0200 Subject: [PATCH] #876 - Remove #586 --- .../org/gnucash/android/ui/account/AccountsActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/gnucash/android/ui/account/AccountsActivity.java b/app/src/main/java/org/gnucash/android/ui/account/AccountsActivity.java index cc2735d33..ae16ef372 100644 --- a/app/src/main/java/org/gnucash/android/ui/account/AccountsActivity.java +++ b/app/src/main/java/org/gnucash/android/ui/account/AccountsActivity.java @@ -154,7 +154,9 @@ public AccountViewPagerAdapter(FragmentManager fm){ @Override public Fragment getItem(int i) { AccountsListFragment currentFragment = (AccountsListFragment) mFragmentPageReferenceMap.get(i); + if (currentFragment == null) { + switch (i) { case INDEX_RECENT_ACCOUNTS_FRAGMENT: currentFragment = AccountsListFragment.newInstance(AccountsListFragment.DisplayMode.RECENT); @@ -169,13 +171,16 @@ public Fragment getItem(int i) { currentFragment = AccountsListFragment.newInstance(AccountsListFragment.DisplayMode.TOP_LEVEL); break; } + mFragmentPageReferenceMap.put(i, currentFragment); + } return currentFragment; } @Override public void destroyItem(ViewGroup container, int position, Object object) { +// #586 By putting this in comment, there is no more crash, but I don't know if there are side effects super.destroyItem(container, position, object); mFragmentPageReferenceMap.remove(position); } @@ -376,6 +381,7 @@ private void init() { @Override protected void onDestroy() { super.onDestroy(); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.edit().putInt(LAST_OPEN_TAB_INDEX, mViewPager.getCurrentItem()).apply(); }