diff options
author | Petar Kukolj <petarkukolj3@yahoo.com> | 2018-11-17 20:13:35 +0100 |
---|---|---|
committer | Petar Kukolj <petarkukolj3@yahoo.com> | 2018-11-17 20:13:35 +0100 |
commit | 0d1b9c4c55436ae77bbd3067f4eb839a71c20934 (patch) | |
tree | 40cba39fe055a734ebc728701f8448599a837544 /app/src/main | |
parent | c2f543ffe4a8f0ceae9ab0b832f055ee023e9637 (diff) | |
download | AntennaPod-0d1b9c4c55436ae77bbd3067f4eb839a71c20934.zip |
Use fragment tags instead of position indexes for saving chosen fragment
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java | 20 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java | 10 |
2 files changed, 9 insertions, 21 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 4c25c5c28..d2a0c3aab 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -669,25 +669,11 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi super.onBackPressed(); } break; - case GO_TO_QUEUE: - if(getLastNavFragment().equals(QueueFragment.TAG)) { + case GO_TO_PAGE: + if(getLastNavFragment().equals(UserPreferences.getBackButtonGoToPage())) { super.onBackPressed(); } else { - loadFragment(QueueFragment.TAG, null); - } - break; - case GO_TO_EPISODES: - if(getLastNavFragment().equals(EpisodesFragment.TAG)) { - super.onBackPressed(); - } else { - loadFragment(EpisodesFragment.TAG, null); - } - break; - case GO_TO_SUBSCRIPTIONS: - if(getLastNavFragment().equals(SubscriptionFragment.TAG)) { - super.onBackPressed(); - } else { - loadFragment(SubscriptionFragment.TAG, null); + loadFragment(UserPreferences.getBackButtonGoToPage(), null); } break; default: super.onBackPressed(); diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index 56af71dc4..ec1767062 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -232,17 +232,19 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc if(newValue.equals("page")) { final Context context = ui.getActivity(); final String[] navTitles = context.getResources().getStringArray(R.array.back_button_go_to_pages); - final int choice[] = { UserPreferences.getBackButtonGoToPage() }; + final String[] navTags = new String[3]; + System.arraycopy(MainActivity.NAV_DRAWER_TAGS, 0, navTags, 0, 3); + final String choice[] = { UserPreferences.getBackButtonGoToPage() }; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.back_button_go_to_page_title); - builder.setSingleChoiceItems(navTitles, choice[0], (dialogInterface, i) -> { + builder.setSingleChoiceItems(navTitles, ArrayUtils.indexOf(navTags, UserPreferences.getBackButtonGoToPage()), (dialogInterface, i) -> { if(i >= 0) { - choice[0] = i; + choice[0] = navTags[i]; } }); builder.setPositiveButton(R.string.confirm_label, (dialogInterface, i) -> { - if (choice[0] != UserPreferences.getBackButtonGoToPage()) { + if (!choice[0].equals(UserPreferences.getBackButtonGoToPage())) { UserPreferences.setBackButtonGoToPage(choice[0]); } }); |