Skip to content

Commit eb37889

Browse files
author
Romain Guy
committed
Don't wait for screen on to finish animations
OldAnimations™ would set their start time during the first frame drawn after calling View.startAnimation(). If this method was invoked while the screen was off, this would cause the animation to start playing when the screen turned back on. Change-Id: Ic45a1af2020a7f5e81c2544bd8f16a6bedbd6849
1 parent 1ac4765 commit eb37889

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/java/android/view/View.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9769,7 +9769,7 @@ public void setScrollBarFadeDuration(int scrollBarFadeDuration) {
97699769
* @attr ref android.R.styleable#View_scrollbarSize
97709770
*/
97719771
public int getScrollBarSize() {
9772-
return mScrollCache == null ? ViewConfiguration.getScrollBarSize() :
9772+
return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() :
97739773
mScrollCache.scrollBarSize;
97749774
}
97759775

@@ -12948,6 +12948,7 @@ public void setBackgroundResource(int resid) {
1294812948
* background
1294912949
*/
1295012950
public void setBackground(Drawable background) {
12951+
//noinspection deprecation
1295112952
setBackgroundDrawable(background);
1295212953
}
1295312954

@@ -14273,7 +14274,15 @@ public void clearAnimation() {
1427314274
*/
1427414275
public void setAnimation(Animation animation) {
1427514276
mCurrentAnimation = animation;
14277+
1427614278
if (animation != null) {
14279+
// If the screen is off assume the animation start time is now instead of
14280+
// the next frame we draw. Keeping the START_ON_FIRST_FRAME start time
14281+
// would cause the animation to start when the screen turns back on
14282+
if (mAttachInfo != null && !mAttachInfo.mScreenOn &&
14283+
animation.getStartTime() == Animation.START_ON_FIRST_FRAME) {
14284+
animation.setStartTime(AnimationUtils.currentAnimationTimeMillis());
14285+
}
1427714286
animation.reset();
1427814287
}
1427914288
}

0 commit comments

Comments
 (0)