summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cyril Mottier <cyrilmottier@gmail.com> 2009-05-05 18:13:48 +0200
committer Cyril Mottier <cyrilmottier@gmail.com> 2009-05-05 18:13:48 +0200
commit238ebb6594bf4cb2548985abcfc6bb838a95a91f (patch)
tree9ec588eec74b2766a078f11149277a1770f7bf88
parent7bc2202d9af2fc9b0e4a28f1c1a5b475a7cf0a25 (diff)
Add of Javadoc comments on undocumented methods.
Use of a constant defined in SensorManager for computing deceleration.
-rw-r--r--core/java/android/widget/Scroller.java44
1 files changed, 35 insertions, 9 deletions
diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java
index c9ace0a35fe1..7c9e06e55abc 100644
--- a/core/java/android/widget/Scroller.java
+++ b/core/java/android/widget/Scroller.java
@@ -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,9 +80,9 @@ public class Scroller {
mFinished = true;
mInterpolator = interpolator;
float ppi = context.getResources().getDisplayMetrics().density * 160.0f;
- mDeceleration = 9.8f // g (m/s^2)
- * 39.37f // inch/meter
- * ppi // pixels per inch
+ 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();
@@ -367,18 +374,37 @@ public class Scroller {
mDurationReciprocal = 1.0f / (float)mDuration;
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;
}
- public void setFinalY(int newY) {
+ /**
+ * 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;
mFinished = false;