From 8eb49e079ec880abf44b21aa47860eef56cb66e7 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 16 Jul 2018 13:33:31 -0700 Subject: [PATCH] Defer starting the high-res thumbnail loader until quick step/scrub - When hitting the home button, we may be loading high-res thumbnails unnecessarily since the high-res loader is already enabled when Launcher is started. Bug: 111515602 Bug: 111156069 Change-Id: I367993b4ddf653b816355df005c745caed5e794a --- .../src/com/android/launcher3/uioverrides/UiFactory.java | 8 ++++++++ quickstep/src/com/android/quickstep/RecentsModel.java | 1 - .../android/quickstep/WindowTransformSwipeHandler.java | 6 ++++++ src/com/android/launcher3/Launcher.java | 6 ++++++ .../com/android/launcher3/uioverrides/UiFactory.java | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index ac9f8634ee..2d0946b890 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -165,6 +165,14 @@ public class UiFactory { } } + public static void onEnterAnimationComplete(Context context) { + // After the transition to home, enable the high-res thumbnail loader if it wasn't enabled + // as a part of quickstep/scrub, so that high-res thumbnails can load the next time we + // enter overview + RecentsModel.getInstance(context).getRecentsTaskLoader() + .getHighResThumbnailLoader().setVisible(true); + } + public static void onLauncherStateOrResumeChanged(Launcher launcher) { LauncherState state = launcher.getStateManager().getState(); DeviceProfile profile = launcher.getDeviceProfile(); diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java index 0c8e47f2bb..0b97f0119f 100644 --- a/quickstep/src/com/android/quickstep/RecentsModel.java +++ b/quickstep/src/com/android/quickstep/RecentsModel.java @@ -232,7 +232,6 @@ public class RecentsModel extends TaskStackChangeListener { public void onStart() { mRecentsTaskLoader.startLoader(mContext); - mRecentsTaskLoader.getHighResThumbnailLoader().setVisible(true); } public void onTrimMemory(int level) { diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 15ff19e260..fdfd073e0a 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -483,6 +483,12 @@ public class WindowTransformSwipeHandler { if (LatencyTrackerCompat.isEnabled(mContext)) { LatencyTrackerCompat.logToggleRecents((int) (mLauncherFrameDrawnTime - mTouchTimeMs)); } + + // This method is only called when STATE_GESTURE_STARTED_QUICKSTEP/ + // STATE_GESTURE_STARTED_QUICKSCRUB is set, so we can enable the high-res thumbnail loader + // here once we are sure that we will end up in an overview state + RecentsModel.getInstance(mContext).getRecentsTaskLoader() + .getHighResThumbnailLoader().setVisible(true); } public void updateInteractionType(@InteractionType int interactionType) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c3c4f5e5ed..4fe35033b2 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -347,6 +347,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, TraceHelper.endSection("Launcher-onCreate"); } + @Override + public void onEnterAnimationComplete() { + super.onEnterAnimationComplete(); + UiFactory.onEnterAnimationComplete(this); + } + @Override public void onConfigurationChanged(Configuration newConfig) { int diff = newConfig.diff(mOldConfig); diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java index 5a7e50fae5..0d727fdbb9 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java @@ -48,6 +48,8 @@ public class UiFactory { public static void onStart(Launcher launcher) { } + public static void onEnterAnimationComplete(Context context) {} + public static void onLauncherStateOrResumeChanged(Launcher launcher) { } public static void onTrimMemory(Launcher launcher, int level) { }