public class DragHelper
extends java.lang.Object
| Constructor and Description |
|---|
DragHelper(int threshold)
Creates a new helper class, which may be used to recognize drag gestures.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getDistance()
Returns the distance, which has been passed while dragging, in pixels.
|
float |
getDragSpeed()
Returns the speed of the drag gesture in pixels per millisecond.
|
int |
getStartPosition()
Returns the position, where the gesture has been started at.
|
boolean |
hasThresholdBeenReached()
Returns, whether the threshold has already been reached, or not.
|
boolean |
isReseted()
Returns, whether the instance has been marked to be reseted, since the method
update(float):void has been called the last time. |
void |
reset()
Marks the instance to be reseted.
|
void |
update(float position)
Updates the instance by adding a new position.
|
public DragHelper(int threshold)
threshold - The distance in pixels, the gesture must last until it is recognized, as an Integer value. The value must be at least 0public final void reset()
update(float):void the next
time. Therefore this method may be used to start recognizing a new drag gesture, whenever a
value is added the next time, while the values of the previous recognition can be still
retrieved until recognizing the new gesture begins.public final boolean isReseted()
update(float):void has been called the last time. See method
reset():void for further information.public final void update(float position)
position - The position, which should be added, as a Float valuepublic final boolean hasThresholdBeenReached()
public final int getDistance()
Integer value or 0,
if the threshold has not been reached yetpublic final int getStartPosition()
Integer value or
-1, if no gesture has been started yetpublic final float getDragSpeed()
Float value or -1, if the threshold has
not been reached yet