Skip to content

Commit 53c9282

Browse files
author
Winson Chung
committed
Using fast-invalidate pattern for screenshot animations.
Change-Id: I33e2dc72986a1e0309b33e9e4a71e131396fc2c8
1 parent e49cf10 commit 53c9282

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -462,16 +462,20 @@ public float getInterpolation(float x) {
462462
anim.addListener(new AnimatorListenerAdapter() {
463463
@Override
464464
public void onAnimationStart(Animator animation) {
465-
mBackgroundView.setAlpha(0f);
465+
mBackgroundView.setFastAlpha(0f);
466466
mBackgroundView.setVisibility(View.VISIBLE);
467-
mScreenshotContainerView.setAlpha(0f);
468-
mScreenshotContainerView.setTranslationX(0f);
469-
mScreenshotContainerView.setTranslationY(0f);
470-
mScreenshotContainerView.setScaleX(SCREENSHOT_SCALE + mBgPaddingScale);
471-
mScreenshotContainerView.setScaleY(SCREENSHOT_SCALE + mBgPaddingScale);
467+
mBackgroundView.fastInvalidate();
468+
mScreenshotContainerView.setFastAlpha(0f);
469+
mScreenshotContainerView.setFastTranslationX(0f);
470+
mScreenshotContainerView.setFastTranslationY(0f);
471+
mScreenshotContainerView.setFastScaleX(SCREENSHOT_SCALE + mBgPaddingScale);
472+
mScreenshotContainerView.setFastScaleY(SCREENSHOT_SCALE + mBgPaddingScale);
472473
mScreenshotContainerView.setVisibility(View.VISIBLE);
473-
mScreenshotFlash.setAlpha(0f);
474+
mScreenshotContainerView.fastInvalidate();
475+
mScreenshotFlash.setFastAlpha(0f);
474476
mScreenshotFlash.setVisibility(View.VISIBLE);
477+
mScreenshotFlash.fastInvalidate();
478+
mScreenshotLayout.invalidate();
475479
}
476480
@Override
477481
public void onAnimationEnd(android.animation.Animator animation) {
@@ -485,11 +489,15 @@ public void onAnimationUpdate(ValueAnimator animation) {
485489
float scaleT = (SCREENSHOT_SCALE + mBgPaddingScale)
486490
- (float) scaleInterpolator.getInterpolation(t)
487491
* (SCREENSHOT_SCALE - SCREENSHOT_DROP_IN_MIN_SCALE);
488-
mBackgroundView.setAlpha(scaleInterpolator.getInterpolation(t) * BACKGROUND_ALPHA);
489-
mScreenshotContainerView.setAlpha(t);
490-
mScreenshotContainerView.setScaleX(scaleT);
491-
mScreenshotContainerView.setScaleY(scaleT);
492-
mScreenshotFlash.setAlpha(flashAlphaInterpolator.getInterpolation(t));
492+
mBackgroundView.setFastAlpha(scaleInterpolator.getInterpolation(t) * BACKGROUND_ALPHA);
493+
mBackgroundView.fastInvalidate();
494+
mScreenshotContainerView.setFastAlpha(t);
495+
mScreenshotContainerView.setFastScaleX(scaleT);
496+
mScreenshotContainerView.setFastScaleY(scaleT);
497+
mScreenshotContainerView.fastInvalidate();
498+
mScreenshotFlash.setFastAlpha(flashAlphaInterpolator.getInterpolation(t));
499+
mScreenshotFlash.fastInvalidate();
500+
mScreenshotLayout.invalidate();
493501
}
494502
});
495503
return anim;
@@ -517,10 +525,13 @@ public void onAnimationUpdate(ValueAnimator animation) {
517525
float scaleT = (SCREENSHOT_DROP_IN_MIN_SCALE + mBgPaddingScale)
518526
- (float) t * (SCREENSHOT_DROP_IN_MIN_SCALE
519527
- SCREENSHOT_FAST_DROP_OUT_MIN_SCALE);
520-
mBackgroundView.setAlpha((1f - t) * BACKGROUND_ALPHA);
521-
mScreenshotContainerView.setAlpha(1f - t);
522-
mScreenshotContainerView.setScaleX(scaleT);
523-
mScreenshotContainerView.setScaleY(scaleT);
528+
mBackgroundView.setFastAlpha((1f - t) * BACKGROUND_ALPHA);
529+
mBackgroundView.fastInvalidate();
530+
mScreenshotContainerView.setFastAlpha(1f - t);
531+
mScreenshotContainerView.setFastScaleX(scaleT);
532+
mScreenshotContainerView.setFastScaleY(scaleT);
533+
mScreenshotContainerView.fastInvalidate();
534+
mScreenshotLayout.invalidate();
524535
}
525536
});
526537
} else {
@@ -555,12 +566,15 @@ public void onAnimationUpdate(ValueAnimator animation) {
555566
float scaleT = (SCREENSHOT_DROP_IN_MIN_SCALE + mBgPaddingScale)
556567
- (float) scaleInterpolator.getInterpolation(t)
557568
* (SCREENSHOT_DROP_IN_MIN_SCALE - SCREENSHOT_DROP_OUT_MIN_SCALE);
558-
mBackgroundView.setAlpha((1f - t) * BACKGROUND_ALPHA);
559-
mScreenshotContainerView.setAlpha(1f - scaleInterpolator.getInterpolation(t));
560-
mScreenshotContainerView.setScaleX(scaleT);
561-
mScreenshotContainerView.setScaleY(scaleT);
562-
mScreenshotContainerView.setTranslationX(t * finalPos.x);
563-
mScreenshotContainerView.setTranslationY(t * finalPos.y);
569+
mBackgroundView.setFastAlpha((1f - t) * BACKGROUND_ALPHA);
570+
mBackgroundView.fastInvalidate();
571+
mScreenshotContainerView.setFastAlpha(1f - scaleInterpolator.getInterpolation(t));
572+
mScreenshotContainerView.setFastScaleX(scaleT);
573+
mScreenshotContainerView.setFastScaleY(scaleT);
574+
mScreenshotContainerView.setFastTranslationX(t * finalPos.x);
575+
mScreenshotContainerView.setFastTranslationY(t * finalPos.y);
576+
mScreenshotContainerView.fastInvalidate();
577+
mScreenshotLayout.invalidate();
564578
}
565579
});
566580
}

0 commit comments

Comments
 (0)