android.view
public
final
class
android.view.VelocityTracker
Summary
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Methods
public
void
addMovement(MotionEvent ev)
Add a user's movement to the tracker. You should call this for the
initial
ACTION_DOWN, the following
ACTION_MOVE events that you receive, and the
final
ACTION_UP. You can, however, call this
for whichever events you desire.
Parameters
ev
| The MotionEvent you received and would like to track.
|
public
void
clear()
Reset the velocity tracker back to its initial state.
public
void
computeCurrentVelocity(int units)
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
getXVelocity() and
getYVelocity().
Parameters
units
| The units you would like the velocity in. A value of 1
provides pixels per millisecond, 1000 provides pixels per second, etc.
|
public
float
getXVelocity()
Retrieve the last computed X velocity. You must first call
computeCurrentVelocity(int) before calling this function.
Returns
- The previously computed X velocity.
public
float
getYVelocity()
Retrieve the last computed Y velocity. You must first call
computeCurrentVelocity(int) before calling this function.
Returns
- The previously computed Y velocity.
Retrieve a new VelocityTracker object to watch the velocity of a
motion. Be sure to call
recycle() when done. You should
generally only maintain an active object while tracking a movement,
so that the VelocityTracker can be re-used elsewhere.
Returns
- Returns a new VelocityTracker.
public
void
recycle()
Return a VelocityTracker object back to be re-used by others. You must
not touch the object after calling this function.