Methods Summary |
---|
public void | addMovement(MotionEvent event)Add a user's movement to the tracker. You should call this for the
initial {@link MotionEvent#ACTION_DOWN}, the following
{@link MotionEvent#ACTION_MOVE} events that you receive, and the
final {@link MotionEvent#ACTION_UP}. You can, however, call this
for whichever events you desire.
if (event == null) {
throw new IllegalArgumentException("event must not be null");
}
nativeAddMovement(mPtr, event);
|
public void | clear()Reset the velocity tracker back to its initial state.
nativeClear(mPtr);
|
public void | computeCurrentVelocity(int units)Equivalent to invoking {@link #computeCurrentVelocity(int, float)} with a maximum
velocity of Float.MAX_VALUE.
nativeComputeCurrentVelocity(mPtr, units, Float.MAX_VALUE);
|
public void | computeCurrentVelocity(int units, float maxVelocity)Compute the current velocity based on the points that have been
collected. Only call this when you actually want to retrieve velocity
information, as it is relatively expensive. You can then retrieve
the velocity with {@link #getXVelocity()} and
{@link #getYVelocity()}.
nativeComputeCurrentVelocity(mPtr, units, maxVelocity);
|
protected void | finalize()
try {
if (mPtr != 0) {
nativeDispose(mPtr);
mPtr = 0;
}
} finally {
super.finalize();
}
|
public boolean | getEstimator(int id, android.view.VelocityTracker$Estimator outEstimator)Get an estimator for the movements of a pointer using past movements of the
pointer to predict future movements.
It is not necessary to call {@link #computeCurrentVelocity(int)} before calling
this method.
if (outEstimator == null) {
throw new IllegalArgumentException("outEstimator must not be null");
}
return nativeGetEstimator(mPtr, id, outEstimator);
|
public float | getXVelocity()Retrieve the last computed X velocity. You must first call
{@link #computeCurrentVelocity(int)} before calling this function.
return nativeGetXVelocity(mPtr, ACTIVE_POINTER_ID);
|
public float | getXVelocity(int id)Retrieve the last computed X velocity. You must first call
{@link #computeCurrentVelocity(int)} before calling this function.
return nativeGetXVelocity(mPtr, id);
|
public float | getYVelocity()Retrieve the last computed Y velocity. You must first call
{@link #computeCurrentVelocity(int)} before calling this function.
return nativeGetYVelocity(mPtr, ACTIVE_POINTER_ID);
|
public float | getYVelocity(int id)Retrieve the last computed Y velocity. You must first call
{@link #computeCurrentVelocity(int)} before calling this function.
return nativeGetYVelocity(mPtr, id);
|
private static native void | nativeAddMovement(long ptr, MotionEvent event)
|
private static native void | nativeClear(long ptr)
|
private static native void | nativeComputeCurrentVelocity(long ptr, int units, float maxVelocity)
|
private static native void | nativeDispose(long ptr)
|
private static native boolean | nativeGetEstimator(long ptr, int id, android.view.VelocityTracker$Estimator outEstimator)
|
private static native float | nativeGetXVelocity(long ptr, int id)
|
private static native float | nativeGetYVelocity(long ptr, int id)
|
private static native long | nativeInitialize(java.lang.String strategy)
|
public static android.view.VelocityTracker | obtain(java.lang.String strategy)Obtains a velocity tracker with the specified strategy.
For testing and comparison purposes only.
if (strategy == null) {
return obtain();
}
return new VelocityTracker(strategy);
|
public static android.view.VelocityTracker | obtain()Retrieve a new VelocityTracker object to watch the velocity of a
motion. Be sure to call {@link #recycle} when done. You should
generally only maintain an active object while tracking a movement,
so that the VelocityTracker can be re-used elsewhere.
VelocityTracker instance = sPool.acquire();
return (instance != null) ? instance : new VelocityTracker(null);
|
public void | recycle()Return a VelocityTracker object back to be re-used by others. You must
not touch the object after calling this function.
if (mStrategy == null) {
clear();
sPool.release(this);
}
|