Removing fades on last item in StackView for major FPS improvement on Prime
Change-Id: I479eb129e80a6087ab55d1de7eed0222d6dacdf6
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index 0cd14d0..03e6e99 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -55,7 +55,6 @@
* Default animation parameters
*/
private static final int DEFAULT_ANIMATION_DURATION = 400;
- private static final int FADE_IN_ANIMATION_DURATION = 800;
private static final int MINIMUM_ANIMATION_DURATION = 50;
private static final int STACK_RELAYOUT_DURATION = 100;
@@ -222,8 +221,6 @@
* Animate the views between different relative indexes within the {@link AdapterViewAnimator}
*/
void transformViewForTransition(int fromIndex, int toIndex, final View view, boolean animate) {
- ObjectAnimator alphaOa;
-
if (!animate) {
((StackFrame) view).cancelSliderAnimator();
view.setRotationX(0f);
@@ -233,22 +230,9 @@
}
if (fromIndex == -1 && toIndex == getNumActiveViews() -1) {
- // Fade item in
- if (view.getAlpha() == 1) {
- view.setAlpha(0);
- }
transformViewAtIndex(toIndex, view, false);
view.setVisibility(VISIBLE);
-
- ((StackFrame) view).cancelAlphaAnimator();
- if (animate) {
- alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 1.0f);
- alphaOa.setDuration(FADE_IN_ANIMATION_DURATION);
- ((StackFrame) view).setAlphaAnimator(alphaOa);
- alphaOa.start();
- } else {
- view.setAlpha(1.0f);
- }
+ view.setAlpha(1.0f);
} else if (fromIndex == 0 && toIndex == 1) {
// Slide item in
((StackFrame) view).cancelSliderAnimator();
@@ -306,13 +290,12 @@
view.setAlpha(1.0f);
view.setVisibility(VISIBLE);
} else if (toIndex == -1) {
- // Fade item out
- ((StackFrame) view).cancelAlphaAnimator();
if (animate) {
- alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 0.0f);
- alphaOa.setDuration(STACK_RELAYOUT_DURATION);
- ((StackFrame) view).setAlphaAnimator(alphaOa);
- alphaOa.start();
+ postDelayed(new Runnable() {
+ public void run() {
+ view.setAlpha(0);
+ }
+ }, STACK_RELAYOUT_DURATION);
} else {
view.setAlpha(0f);
}
@@ -485,7 +468,6 @@
}
private static class StackFrame extends FrameLayout {
- WeakReference<ObjectAnimator> alphaAnimator;
WeakReference<ObjectAnimator> transformAnimator;
WeakReference<ObjectAnimator> sliderAnimator;
@@ -493,10 +475,6 @@
super(context);
}
- void setAlphaAnimator(ObjectAnimator oa) {
- alphaAnimator = new WeakReference<ObjectAnimator>(oa);
- }
-
void setTransformAnimator(ObjectAnimator oa) {
transformAnimator = new WeakReference<ObjectAnimator>(oa);
}
@@ -505,17 +483,6 @@
sliderAnimator = new WeakReference<ObjectAnimator>(oa);
}
- boolean cancelAlphaAnimator() {
- if (alphaAnimator != null) {
- ObjectAnimator oa = alphaAnimator.get();
- if (oa != null) {
- oa.cancel();
- return true;
- }
- }
- return false;
- }
-
boolean cancelTransformAnimator() {
if (transformAnimator != null) {
ObjectAnimator oa = transformAnimator.get();