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

Commit 72fd11e6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improve View scrollbar fade scheduling efficiency" into main

parents 8c0e33d5 13801aec
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -21115,7 +21115,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *        should start; when the delay is 0, the animation starts
     *        immediately
     *
     * @param invalidate Whether this method should call invalidate
     * @param invalidate Whether this method should call invalidate if an animation
     *        is scheduled
     *
     * @return true if the animation is played, false otherwise
     *
@@ -21141,11 +21142,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (isHorizontalScrollBarEnabled() || isVerticalScrollBarEnabled()) {
            if (invalidate) {
                // Invalidate to show the scrollbars
                postInvalidateOnAnimation();
            }
            if (scrollCache.state == ScrollabilityCache.OFF) {
                // FIXME: this is copied from WindowManagerService.
                // We should get this value from the system when it
@@ -21160,10 +21156,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            scrollCache.fadeStartTime = fadeStartTime;
            scrollCache.state = ScrollabilityCache.ON;
            // Schedule our fader to run, unscheduling any old ones first
            // Schedule our fader to run if it's not already scheduled
            if (!scrollCache.fadeScrollBarsScheduled) {
                if (invalidate) {
                    // Invalidate to show the scrollbars
                    postInvalidateOnAnimation();
                }
                if (mAttachInfo != null) {
                mAttachInfo.mHandler.removeCallbacks(scrollCache);
                mAttachInfo.mHandler.postAtTime(scrollCache, fadeStartTime);
                    final Handler handler = mAttachInfo.mHandler;
                    scrollCache.handler = handler;
                    scrollCache.fadeScrollBarsScheduled = true;
                    handler.postAtTime(scrollCache, fadeStartTime);
                }
            }
            return true;
@@ -32842,6 +32846,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        public static final int FADING = 2;
        public boolean fadeScrollBars;
        public boolean fadeScrollBarsScheduled;
        public int fadingEdgeLength;
        public int scrollBarDefaultDelayBeforeFade;
@@ -32870,6 +32875,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        public long fadeStartTime;
        /**
         * Handler used for scheduling fade animations.
         */
        Handler handler;
        /**
         * The current state of the scrollbars: ON, OFF, or FADING
@@ -32928,6 +32937,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        public void run() {
            long now = AnimationUtils.currentAnimationTimeMillis();
            if (now >= fadeStartTime) {
                fadeScrollBarsScheduled = false;
                handler = null;
                // the animation fades the scrollbars out by changing
                // the opacity (alpha) from fully opaque to fully
@@ -32948,6 +32959,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                // Kick off the fade animation
                host.invalidate(true);
            } else if (handler != null) {
                // Reschedule the fade animation
                handler.postAtTime(this, fadeStartTime);
            }
        }
    }