Skip to content

Commit e3bb0ec

Browse files
Adam CohenAndroid (Google) Code Review
authored andcommitted
Merge "Removing fades on last item in StackView for major FPS improvement on Prime" into ics-mr0
2 parents 2dd2e5b + c798b66 commit e3bb0ec

File tree

1 file changed

+6
-39
lines changed

1 file changed

+6
-39
lines changed

core/java/android/widget/StackView.java

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public class StackView extends AdapterViewAnimator {
5555
* Default animation parameters
5656
*/
5757
private static final int DEFAULT_ANIMATION_DURATION = 400;
58-
private static final int FADE_IN_ANIMATION_DURATION = 800;
5958
private static final int MINIMUM_ANIMATION_DURATION = 50;
6059
private static final int STACK_RELAYOUT_DURATION = 100;
6160

@@ -222,8 +221,6 @@ private void initStackView() {
222221
* Animate the views between different relative indexes within the {@link AdapterViewAnimator}
223222
*/
224223
void transformViewForTransition(int fromIndex, int toIndex, final View view, boolean animate) {
225-
ObjectAnimator alphaOa;
226-
227224
if (!animate) {
228225
((StackFrame) view).cancelSliderAnimator();
229226
view.setRotationX(0f);
@@ -233,22 +230,9 @@ void transformViewForTransition(int fromIndex, int toIndex, final View view, boo
233230
}
234231

235232
if (fromIndex == -1 && toIndex == getNumActiveViews() -1) {
236-
// Fade item in
237-
if (view.getAlpha() == 1) {
238-
view.setAlpha(0);
239-
}
240233
transformViewAtIndex(toIndex, view, false);
241234
view.setVisibility(VISIBLE);
242-
243-
((StackFrame) view).cancelAlphaAnimator();
244-
if (animate) {
245-
alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 1.0f);
246-
alphaOa.setDuration(FADE_IN_ANIMATION_DURATION);
247-
((StackFrame) view).setAlphaAnimator(alphaOa);
248-
alphaOa.start();
249-
} else {
250-
view.setAlpha(1.0f);
251-
}
235+
view.setAlpha(1.0f);
252236
} else if (fromIndex == 0 && toIndex == 1) {
253237
// Slide item in
254238
((StackFrame) view).cancelSliderAnimator();
@@ -306,13 +290,12 @@ void transformViewForTransition(int fromIndex, int toIndex, final View view, boo
306290
view.setAlpha(1.0f);
307291
view.setVisibility(VISIBLE);
308292
} else if (toIndex == -1) {
309-
// Fade item out
310-
((StackFrame) view).cancelAlphaAnimator();
311293
if (animate) {
312-
alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 0.0f);
313-
alphaOa.setDuration(STACK_RELAYOUT_DURATION);
314-
((StackFrame) view).setAlphaAnimator(alphaOa);
315-
alphaOa.start();
294+
postDelayed(new Runnable() {
295+
public void run() {
296+
view.setAlpha(0);
297+
}
298+
}, STACK_RELAYOUT_DURATION);
316299
} else {
317300
view.setAlpha(0f);
318301
}
@@ -485,18 +468,13 @@ private void updateChildTransforms() {
485468
}
486469

487470
private static class StackFrame extends FrameLayout {
488-
WeakReference<ObjectAnimator> alphaAnimator;
489471
WeakReference<ObjectAnimator> transformAnimator;
490472
WeakReference<ObjectAnimator> sliderAnimator;
491473

492474
public StackFrame(Context context) {
493475
super(context);
494476
}
495477

496-
void setAlphaAnimator(ObjectAnimator oa) {
497-
alphaAnimator = new WeakReference<ObjectAnimator>(oa);
498-
}
499-
500478
void setTransformAnimator(ObjectAnimator oa) {
501479
transformAnimator = new WeakReference<ObjectAnimator>(oa);
502480
}
@@ -505,17 +483,6 @@ void setSliderAnimator(ObjectAnimator oa) {
505483
sliderAnimator = new WeakReference<ObjectAnimator>(oa);
506484
}
507485

508-
boolean cancelAlphaAnimator() {
509-
if (alphaAnimator != null) {
510-
ObjectAnimator oa = alphaAnimator.get();
511-
if (oa != null) {
512-
oa.cancel();
513-
return true;
514-
}
515-
}
516-
return false;
517-
}
518-
519486
boolean cancelTransformAnimator() {
520487
if (transformAnimator != null) {
521488
ObjectAnimator oa = transformAnimator.get();

0 commit comments

Comments
 (0)