Ensure that layers are properly removed after animation

Bug 19243980

Change-Id: Ic1d54f92051f7d937878898cae210ec18ecbaff8
This commit is contained in:
Adam Cohen
2015-02-13 16:14:33 -08:00
parent c87775d8e6
commit 80e6beb48c
2 changed files with 59 additions and 36 deletions

View File

@@ -2091,7 +2091,7 @@ public class Workspace extends SmoothPagedView
}
Animator getChangeStateAnimation(final State state, boolean animated,
ArrayList<View> layerViews) {
HashMap<View, Integer> 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<View> layerViews) {
HashMap<View, Integer> 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);