From 24500ce1fd7b02eaf435d4a15ee9591fbb1ed77a Mon Sep 17 00:00:00 2001 From: Raff Tsai Date: Mon, 9 Sep 2019 10:19:46 +0800 Subject: [PATCH] Fix settings panel refresh issue We use updatePanelWithAnimation() to make old panel animated out and new panel animated in. But if old panel is in background, we don't need the animation out process. Use a flag mForceCreation to check, if activity is onStop() means it is in background, we don't need the animation. Fixes: 140541182 Test: manual Change-Id: I9a2f555dba5417a108ce35fac25a62cf7a8b1d8b --- .../settings/panel/SettingsPanelActivity.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java index 86931866afc..ce437bbdf72 100644 --- a/src/com/android/settings/panel/SettingsPanelActivity.java +++ b/src/com/android/settings/panel/SettingsPanelActivity.java @@ -59,6 +59,8 @@ public class SettingsPanelActivity extends FragmentActivity { */ public static final String KEY_MEDIA_PACKAGE_NAME = "PANEL_MEDIA_PACKAGE_NAME"; + private boolean mForceCreation = false; + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -70,7 +72,19 @@ public class SettingsPanelActivity extends FragmentActivity { protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); - createOrUpdatePanel(false /* shouldForceCreation */); + createOrUpdatePanel(mForceCreation); + } + + @Override + protected void onResume() { + super.onResume(); + mForceCreation = false; + } + + @Override + protected void onStop() { + super.onStop(); + mForceCreation = true; } private void createOrUpdatePanel(boolean shouldForceCreation) { @@ -91,7 +105,7 @@ public class SettingsPanelActivity extends FragmentActivity { final FragmentManager fragmentManager = getSupportFragmentManager(); final Fragment fragment = fragmentManager.findFragmentById(R.id.main_content); - // If fragment already exists, we will need to update panel with animation. + // If fragment already exists and visible, we will need to update panel with animation. if (!shouldForceCreation && fragment != null && fragment instanceof PanelFragment) { final PanelFragment panelFragment = (PanelFragment) fragment; panelFragment.setArguments(mBundle);