From 80e6beb48ca71a321f667e79fe35a7ab2fb4c2bf Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 13 Feb 2015 16:14:33 -0800 Subject: Ensure that layers are properly removed after animation Bug 19243980 Change-Id: Ic1d54f92051f7d937878898cae210ec18ecbaff8 --- src/com/android/launcher3/Workspace.java | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/com/android/launcher3/Workspace.java') diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 44d77571b..402172717 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2091,7 +2091,7 @@ public class Workspace extends SmoothPagedView } Animator getChangeStateAnimation(final State state, boolean animated, - ArrayList layerViews) { + HashMap layerViews) { return getChangeStateAnimation(state, animated, 0, -1, layerViews); } @@ -2222,7 +2222,7 @@ public class Workspace extends SmoothPagedView } Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage, - ArrayList layerViews) { + HashMap layerViews) { if (mState == state) { return null; } @@ -2352,7 +2352,7 @@ public class Workspace extends SmoothPagedView cl.setShortcutAndWidgetAlpha(mNewAlphas[i]); } else { if (layerViews != null) { - layerViews.add(cl); + layerViews.put(cl, Launcher.BUILD_LAYER); } if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) { LauncherViewPropertyAnimator alphaAnim = @@ -2389,12 +2389,12 @@ public class Workspace extends SmoothPagedView pageIndicatorAlpha = ValueAnimator.ofFloat(0, 0); } - Animator hotseatAlpha = new LauncherViewPropertyAnimator(hotseat) - .alpha(finalHotseatAndPageIndicatorAlpha).withLayer(); + LauncherViewPropertyAnimator hotseatAlpha = new LauncherViewPropertyAnimator(hotseat) + .alpha(finalHotseatAndPageIndicatorAlpha); hotseatAlpha.addListener(new AlphaUpdateListener(hotseat)); - Animator overviewPanelAlpha = new LauncherViewPropertyAnimator(overviewPanel) - .alpha(finalOverviewPanelAlpha).withLayer(); + LauncherViewPropertyAnimator overviewPanelAlpha = + new LauncherViewPropertyAnimator(overviewPanel).alpha(finalOverviewPanelAlpha); overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); // For animation optimations, we may need to provide the Launcher transition @@ -2402,8 +2402,14 @@ public class Workspace extends SmoothPagedView hotseat.setLayerType(View.LAYER_TYPE_HARDWARE, null); overviewPanel.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (layerViews != null) { - layerViews.add(hotseat); - layerViews.add(overviewPanel); + // If layerViews is not null, we add these views, and indicate that + // the caller can manage layer state. + layerViews.put(hotseat, Launcher.BUILD_AND_SET_LAYER); + layerViews.put(overviewPanel, Launcher.BUILD_AND_SET_LAYER); + } else { + // Otherwise let the animator handle layer management. + hotseatAlpha.withLayer(); + overviewPanelAlpha.withLayer(); } if (workspaceToOverview) { @@ -2421,12 +2427,17 @@ public class Workspace extends SmoothPagedView hotseatAlpha.setDuration(duration); if (searchBar != null) { - Animator searchBarAlpha = new LauncherViewPropertyAnimator(searchBar) - .alpha(finalSearchBarAlpha).withLayer(); + LauncherViewPropertyAnimator searchBarAlpha = new LauncherViewPropertyAnimator(searchBar) + .alpha(finalSearchBarAlpha); searchBarAlpha.addListener(new AlphaUpdateListener(searchBar)); searchBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (layerViews != null) { - layerViews.add(searchBar); + // If layerViews is not null, we add these views, and indicate that + // the caller can manage layer state. + layerViews.put(searchBar, Launcher.BUILD_AND_SET_LAYER); + } else { + // Otherwise let the animator handle layer management. + searchBarAlpha.withLayer(); } searchBarAlpha.setDuration(duration); anim.play(searchBarAlpha); -- cgit v1.2.3