From f0988f1fb1d89af048dd98adfe1b1c1162899cfb Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 3 Mar 2021 08:39:34 -0800 Subject: [PATCH] Prevent NPE inside AllAppsTransitionController Bug: 181911438 Test: manual Change-Id: Ia2cfe43512c0336232fc6787eb955d476280e3b8 --- .../allapps/AllAppsTransitionController.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index dc58c99c99..a48e4232cf 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -144,11 +144,14 @@ public class AllAppsTransitionController implements StateHandler, */ public void setProgress(float progress) { mProgress = progress; + mScrimView.setProgress(progress); float shiftCurrent = progress * mShiftRange; - mAppsView.setTranslationY(shiftCurrent); if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && mSearchImeEnabled) { + if (mInsetController == null) { + setupInsetTransitionController(); + } mInsetController.setProgress(progress); } } @@ -240,13 +243,17 @@ public class AllAppsTransitionController implements StateHandler, mAppsView = appsView; mScrimView = scrimView; if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) { - mInsetController = new AllAppsInsetTransitionController(mShiftRange, mAppsView); - mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS, - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + setupInsetTransitionController(); } } + private void setupInsetTransitionController() { + mInsetController = new AllAppsInsetTransitionController(mShiftRange, mAppsView); + mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS, + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + /** * Updates the total scroll range but does not update the UI. */