From 826cdcd32fa91afe932c8c07be1a4e92a6f73301 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 2 Jul 2019 14:35:11 -0700 Subject: [PATCH] Fix bug where icon is no present during app close animation. * WindowTransformSwipeHandler closes all AbstractFloatingViews, including ListenerView, which results in FloatingIconView getting removed. * In IconLoadResult.onIconLoaded, we remove the check for isIconLoaded since its not needed. This was also causing a race condition since isIconLoaded is not set to true until after we tell onIconLoaded to run. * In BaseDragLayer, we have a delay before checking if the view is open and then closing the floating view if true. This caused issues since we reycle the view. Now we check if the view is open before running the delay to call close. Bug: 136044361 Change-Id: I7442a589a62c3cdf90b70d146e0ecf3e4300ddf7 --- .../android/quickstep/WindowTransformSwipeHandler.java | 3 ++- src/com/android/launcher3/views/BaseDragLayer.java | 10 ++++------ src/com/android/launcher3/views/FloatingIconView.java | 10 +++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index f1d1141bcd..ac7ba3fc3d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -505,7 +505,8 @@ public class WindowTransformSwipeHandler initAnimFactory.run(); } } - AbstractFloatingView.closeAllOpenViews(activity, mWasLauncherAlreadyVisible); + AbstractFloatingView.closeAllOpenViewsExcept(activity, mWasLauncherAlreadyVisible, + AbstractFloatingView.TYPE_LISTENER); if (mWasLauncherAlreadyVisible) { mStateCallback.setState(STATE_LAUNCHER_DRAWN); diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 53686cae48..1e70c7f812 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -224,12 +224,10 @@ public abstract class BaseDragLayer if (child instanceof AbstractFloatingView) { // Handles the case where the view is removed without being properly closed. // This can happen if something goes wrong during a state change/transition. - postDelayed(() -> { - AbstractFloatingView floatingView = (AbstractFloatingView) child; - if (floatingView.isOpen()) { - floatingView.close(false); - } - }, SINGLE_FRAME_MS); + AbstractFloatingView floatingView = (AbstractFloatingView) child; + if (floatingView.isOpen()) { + postDelayed(() -> floatingView.close(false), SINGLE_FRAME_MS); + } } } diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index b6c4fedac9..ab4b576bf9 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -574,17 +574,17 @@ public class FloatingIconView extends View implements if (cancellationSignal.isCanceled()) { return; } - if (mIconLoadResult.isIconLoaded) { - setIcon(originalView, mIconLoadResult.drawable, mIconLoadResult.badge, - mIconLoadResult.iconOffset); - } + + setIcon(originalView, mIconLoadResult.drawable, mIconLoadResult.badge, + mIconLoadResult.iconOffset); + // Delay swapping views until the icon is loaded to prevent a flash. setVisibility(VISIBLE); originalView.setVisibility(INVISIBLE); }; + mLoadIconSignal = cancellationSignal; } } - mLoadIconSignal = cancellationSignal; } private void setBackgroundDrawableBounds(float scale) {