From 23eeb4353dc96504f1fa6a8fbc8a5e1b5256c757 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 13 Oct 2017 13:49:31 +0200 Subject: [PATCH] make main page changes display emediatly --- app/src/main/java/org/schabi/newpipe/MainActivity.java | 6 ++++++ .../java/org/schabi/newpipe/fragments/MainFragment.java | 1 + .../schabi/newpipe/settings/ContentSettingsFragment.java | 3 +++ app/src/main/java/org/schabi/newpipe/util/Constants.java | 1 + .../main/java/org/schabi/newpipe/util/NavigationHelper.java | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 67689d541..3ff55cb76 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -119,6 +119,12 @@ public class MainActivity extends AppCompatActivity implements HistoryListener { }); } + if(sharedPreferences.getBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false)) { + if (DEBUG) Log.d(TAG, "main page has changed, recreating main fragment..."); + sharedPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false).apply(); + NavigationHelper.openMainActivity(this); + } + } @Override diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 48f2d150e..ba09f4001 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -30,6 +30,7 @@ import org.schabi.newpipe.fragments.list.kiosk.KioskFragment; import org.schabi.newpipe.fragments.subscription.SubscriptionFragment; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; +import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.NavigationHelper; diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 381c20ff1..aeba78cbd 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; +import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.KioskTranslator; public class ContentSettingsFragment extends BasePreferenceFragment { @@ -88,6 +89,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment { mainPageContentPref.setSummary(getMainPageSummeryByKey(newValue)); } + defaultPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, true).apply(); + return true; } }); diff --git a/app/src/main/java/org/schabi/newpipe/util/Constants.java b/app/src/main/java/org/schabi/newpipe/util/Constants.java index f9329b0be..08e64aceb 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Constants.java +++ b/app/src/main/java/org/schabi/newpipe/util/Constants.java @@ -9,4 +9,5 @@ public class Constants { public static final String KEY_QUERY = "key_query"; public static final String KEY_THEME_CHANGE = "key_theme_change"; + public static final String KEY_MAIN_PAGE_CHANGE = "key_main_page_change"; } diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index b30407315..b08251436 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -94,7 +94,7 @@ public class NavigationHelper { if (!popped) openMainFragment(fragmentManager); } - private static void openMainFragment(FragmentManager fragmentManager) { + public static void openMainFragment(FragmentManager fragmentManager) { InfoCache.getInstance().trimCache(); fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);