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

Commit 98d4e403 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing Spline parameters when changing duration/position of Overscroller

> This allows the scroller to be used in Launcher3 instead of a custom copy

Bug: 183966408
Test: Verified with Launcher3
Change-Id: I1c945774d0323fabcf4bfd5a02c2eaf8e95a218d
parent 04e05de6
Loading
Loading
Loading
Loading
+6 −23
Original line number Original line Diff line number Diff line
@@ -232,11 +232,8 @@ public class OverScroller {
     *
     *
     * @return The duration of the scroll in milliseconds.
     * @return The duration of the scroll in milliseconds.
     *
     *
     * @hide Pending removal once nothing depends on it
     * @hide
     * @deprecated OverScrollers don't necessarily have a fixed duration.
     *             This function will lie to the best of its ability.
     */
     */
    @Deprecated
    public final int getDuration() {
    public final int getDuration() {
        return Math.max(mScrollerX.mDuration, mScrollerY.mDuration);
        return Math.max(mScrollerX.mDuration, mScrollerY.mDuration);
    }
    }
@@ -249,13 +246,8 @@ public class OverScroller {
     * @see #setFinalX(int)
     * @see #setFinalX(int)
     * @see #setFinalY(int)
     * @see #setFinalY(int)
     *
     *
     * @hide Pending removal once nothing depends on it
     * @hide
     * @deprecated OverScrollers don't necessarily have a fixed duration.
     *             Instead of setting a new final position and extending
     *             the duration of an existing scroll, use startScroll
     *             to begin a new animation.
     */
     */
    @Deprecated
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    public void extendDuration(int extend) {
    public void extendDuration(int extend) {
        mScrollerX.extendDuration(extend);
        mScrollerX.extendDuration(extend);
@@ -269,13 +261,8 @@ public class OverScroller {
     * @see #extendDuration(int)
     * @see #extendDuration(int)
     * @see #setFinalY(int)
     * @see #setFinalY(int)
     *
     *
     * @hide Pending removal once nothing depends on it
     * @hide
     * @deprecated OverScroller's final position may change during an animation.
     *             Instead of setting a new final position and extending
     *             the duration of an existing scroll, use startScroll
     *             to begin a new animation.
     */
     */
    @Deprecated
    public void setFinalX(int newX) {
    public void setFinalX(int newX) {
        mScrollerX.setFinalPosition(newX);
        mScrollerX.setFinalPosition(newX);
    }
    }
@@ -287,13 +274,8 @@ public class OverScroller {
     * @see #extendDuration(int)
     * @see #extendDuration(int)
     * @see #setFinalX(int)
     * @see #setFinalX(int)
     *
     *
     * @hide Pending removal once nothing depends on it
     * @hide
     * @deprecated OverScroller's final position may change during an animation.
     *             Instead of setting a new final position and extending
     *             the duration of an existing scroll, use startScroll
     *             to begin a new animation.
     */
     */
    @Deprecated
    public void setFinalY(int newY) {
    public void setFinalY(int newY) {
        mScrollerY.setFinalPosition(newY);
        mScrollerY.setFinalPosition(newY);
    }
    }
@@ -710,13 +692,14 @@ public class OverScroller {


        void setFinalPosition(int position) {
        void setFinalPosition(int position) {
            mFinal = position;
            mFinal = position;
            mSplineDistance = mFinal - mStart;
            mFinished = false;
            mFinished = false;
        }
        }


        void extendDuration(int extend) {
        void extendDuration(int extend) {
            final long time = AnimationUtils.currentAnimationTimeMillis();
            final long time = AnimationUtils.currentAnimationTimeMillis();
            final int elapsedTime = (int) (time - mStartTime);
            final int elapsedTime = (int) (time - mStartTime);
            mDuration = elapsedTime + extend;
            mDuration = mSplineDuration = elapsedTime + extend;
            mFinished = false;
            mFinished = false;
        }
        }