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

Commit 238ebb65 authored by Cyril Mottier's avatar Cyril Mottier
Browse files

Add of Javadoc comments on undocumented methods.

Use of a constant defined in SensorManager for computing deceleration.
parent 7bc2202d
Loading
Loading
Loading
Loading
+35 −9
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.widget;

import android.content.Context;
import android.hardware.SensorManager;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
@@ -79,7 +80,7 @@ public class Scroller {
        mFinished = true;
        mInterpolator = interpolator;
        float ppi = context.getResources().getDisplayMetrics().density * 160.0f;
        mDeceleration = 9.8f   // g (m/s^2)
        mDeceleration = SensorManager.GRAVITY_EARTH   // g (m/s^2)
                      * 39.37f                        // inch/meter
                      * ppi                           // pixels per inch
                      * ViewConfiguration.getScrollFriction();
@@ -347,7 +348,11 @@ public class Scroller {
    }
    
    /**
     * Stops the animation. Contrary to {@link #forceFinished(boolean)},
     * aborting the animating cause the scroller to move to the final x and y
     * position
     *
     * @see #forceFinished(boolean)
     */
    public void abortAnimation() {
        mCurrX = mFinalX;
@@ -356,10 +361,12 @@ public class Scroller {
    }
    
    /**
     * Extend the scroll animation. This allows a running animation to 
     * scroll further and longer, when used with setFinalX() or setFinalY().
     * Extend the scroll animation. This allows a running animation to scroll
     * further and longer, when used with {@link #setFinalX()} or {@link setFinalY()}.
     *
     * @param extend Additional time to scroll in milliseconds.
     * @see #setFinalX(int)
     * @see #setFinalY(int)
     */
    public void extendDuration(int extend) {
        int passed = timePassed();
@@ -368,16 +375,35 @@ public class Scroller {
        mFinished = false;
    }

    /**
     * Returns the time elapsed since the beginning of the scrolling.
     *
     * @return The elapsed time in milliseconds.
     */
    public int timePassed() {
        return (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
    }

    /**
     * Sets the final position (X) for this scroller.
     *
     * @param newX The new X offset as an absolute distance from the origin.
     * @see #extendDuration(int)
     * @see #setFinalY(int)
     */
    public void setFinalX(int newX) {
        mFinalX = newX;
        mDeltaX = mFinalX - mStartX;
        mFinished = false;
    }

    /**
     * Sets the final position (Y) for this scroller.
     *
     * @param newY The new Y offset as an absolute distance from the origin.
     * @see #extendDuration(int)
     * @see #setFinalX(int)
     */
    public void setFinalY(int newY) {
        mFinalY = newY;
        mDeltaY = mFinalY - mStartY;