Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb378890 authored by Romain Guy's avatar Romain Guy
Browse files

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
parent 1ac4765e
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -9769,7 +9769,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @attr ref android.R.styleable#View_scrollbarSize
     * @attr ref android.R.styleable#View_scrollbarSize
     */
     */
    public int getScrollBarSize() {
    public int getScrollBarSize() {
        return mScrollCache == null ? ViewConfiguration.getScrollBarSize() :
        return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() :
                mScrollCache.scrollBarSize;
                mScrollCache.scrollBarSize;
    }
    }
@@ -12948,6 +12948,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     *        background
     *        background
     */
     */
    public void setBackground(Drawable background) {
    public void setBackground(Drawable background) {
        //noinspection deprecation
        setBackgroundDrawable(background);
        setBackgroundDrawable(background);
    }
    }
@@ -14273,7 +14274,15 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
     */
    public void setAnimation(Animation animation) {
    public void setAnimation(Animation animation) {
        mCurrentAnimation = animation;
        mCurrentAnimation = animation;
        if (animation != null) {
        if (animation != null) {
            // If the screen is off assume the animation start time is now instead of
            // the next frame we draw. Keeping the START_ON_FIRST_FRAME start time
            // would cause the animation to start when the screen turns back on
            if (mAttachInfo != null && !mAttachInfo.mScreenOn &&
                    animation.getStartTime() == Animation.START_ON_FIRST_FRAME) {
                animation.setStartTime(AnimationUtils.currentAnimationTimeMillis());
            }
            animation.reset();
            animation.reset();
        }
        }
    }
    }