summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2015-02-14 01:05:58 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-14 01:05:58 +0000
commit97079bc7d55e031f5f804a86c6cc7ff929395838 (patch)
treef649fe616397545e0348c28aa6dcb1f84f5a10f5 /src
parentf48e71d116128e24accf4a2662d9918e3555c127 (diff)
parent80e6beb48ca71a321f667e79fe35a7ab2fb4c2bf (diff)
downloadandroid_packages_apps_Trebuchet-97079bc7d55e031f5f804a86c6cc7ff929395838.tar.gz
android_packages_apps_Trebuchet-97079bc7d55e031f5f804a86c6cc7ff929395838.tar.bz2
android_packages_apps_Trebuchet-97079bc7d55e031f5f804a86c6cc7ff929395838.zip
am 80e6beb4: Ensure that layers are properly removed after animation
* commit '80e6beb48ca71a321f667e79fe35a7ab2fb4c2bf': Ensure that layers are properly removed after animation
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java60
-rw-r--r--src/com/android/launcher3/Workspace.java35
2 files changed, 59 insertions, 36 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 6a4fc89ba..7e2ae4ede 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -304,6 +304,9 @@ public class Launcher extends Activity
private View.OnTouchListener mHapticFeedbackTouchListener;
+ public static final int BUILD_LAYER = 0;
+ public static final int BUILD_AND_SET_LAYER = 1;
+
// Related to the auto-advancing of widgets
private final int ADVANCE_MSG = 1;
private final int mAdvanceInterval = 20000;
@@ -3287,7 +3290,7 @@ public class Launcher extends Activity
final View fromView = mWorkspace;
final AppsCustomizeTabHost toView = mAppsCustomizeTabHost;
- final ArrayList<View> layerViews = new ArrayList<View>();
+ final HashMap<View, Integer> layerViews = new HashMap<View, Integer>();
Workspace.State workspaceState = contentType == AppsCustomizePagedView.ContentType.Widgets ?
Workspace.State.OVERVIEW_HIDDEN : Workspace.State.NORMAL_HIDDEN;
@@ -3347,8 +3350,7 @@ public class Launcher extends Activity
}
final float initAlpha = alpha;
- revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- layerViews.add(revealView);
+ layerViews.put(revealView, BUILD_AND_SET_LAYER);
PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", initAlpha, 1f);
PropertyValuesHolder panelDriftY =
PropertyValuesHolder.ofFloat("translationY", yDrift, 0);
@@ -3365,8 +3367,7 @@ public class Launcher extends Activity
if (page != null) {
page.setVisibility(View.VISIBLE);
- page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- layerViews.add(page);
+ layerViews.put(page, BUILD_AND_SET_LAYER);
ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0);
page.setTranslationY(yDrift);
@@ -3422,9 +3423,11 @@ public class Launcher extends Activity
dispatchOnLauncherTransitionEnd(toView, animated, false);
revealView.setVisibility(View.INVISIBLE);
- revealView.setLayerType(View.LAYER_TYPE_NONE, null);
- if (page != null) {
- page.setLayerType(View.LAYER_TYPE_NONE, null);
+
+ for (View v : layerViews.keySet()) {
+ if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
+ v.setLayerType(View.LAYER_TYPE_NONE, null);
+ }
}
content.setPageBackgroundsVisible(true);
@@ -3456,12 +3459,16 @@ public class Launcher extends Activity
dispatchOnLauncherTransitionStart(toView, animated, false);
revealView.setAlpha(initAlpha);
+
+ for (View v : layerViews.keySet()) {
+ if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
+ v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ }
+ }
+
if (Utilities.isLmpOrAbove()) {
- for (int i = 0; i < layerViews.size(); i++) {
- View v = layerViews.get(i);
- if (v != null) {
- if (Utilities.isViewAttachedToWindow(v)) v.buildLayer();
- }
+ for (View v : layerViews.keySet()) {
+ if (Utilities.isViewAttachedToWindow(v)) v.buildLayer();
}
}
mStateAnimation.start();
@@ -3517,7 +3524,7 @@ public class Launcher extends Activity
final View fromView = mAppsCustomizeTabHost;
final View toView = mWorkspace;
Animator workspaceAnim = null;
- final ArrayList<View> layerViews = new ArrayList<View>();
+ final HashMap<View, Integer> layerViews = new HashMap<View, Integer>();
if (toState == Workspace.State.NORMAL) {
workspaceAnim = mWorkspace.getChangeStateAnimation(
@@ -3589,7 +3596,7 @@ public class Launcher extends Activity
xDrift = 0;
}
- revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ layerViews.put(revealView, BUILD_AND_SET_LAYER);
TimeInterpolator decelerateInterpolator = material ?
new LogDecelerateInterpolator(100, 0) :
new DecelerateInterpolator(1f);
@@ -3623,7 +3630,7 @@ public class Launcher extends Activity
}
if (page != null) {
- page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ layerViews.put(page, BUILD_AND_SET_LAYER);
ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY",
0, yDrift);
@@ -3691,10 +3698,12 @@ public class Launcher extends Activity
onCompleteRunnable.run();
}
- revealView.setLayerType(View.LAYER_TYPE_NONE, null);
- if (page != null) {
- page.setLayerType(View.LAYER_TYPE_NONE, null);
+ for (View v : layerViews.keySet()) {
+ if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
+ v.setLayerType(View.LAYER_TYPE_NONE, null);
+ }
}
+
content.setPageBackgroundsVisible(true);
// Unhide side pages
int count = content.getChildCount();
@@ -3728,12 +3737,15 @@ public class Launcher extends Activity
dispatchOnLauncherTransitionStart(fromView, animated, false);
dispatchOnLauncherTransitionStart(toView, animated, false);
+ for (View v : layerViews.keySet()) {
+ if (layerViews.get(v) == BUILD_AND_SET_LAYER) {
+ v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ }
+ }
+
if (Utilities.isLmpOrAbove()) {
- for (int i = 0; i < layerViews.size(); i++) {
- View v = layerViews.get(i);
- if (v != null) {
- if (Utilities.isViewAttachedToWindow(v)) v.buildLayer();
- }
+ for (View v : layerViews.keySet()) {
+ if (Utilities.isViewAttachedToWindow(v)) v.buildLayer();
}
}
mStateAnimation.start();
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 3de0b8e7e..661c3ce4d 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2065,7 +2065,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);
}
@@ -2196,7 +2196,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;
}
@@ -2326,7 +2326,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 =
@@ -2363,12 +2363,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
@@ -2376,8 +2376,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) {
@@ -2395,12 +2401,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);