public class DragHelper
extends java.lang.Object
| Constructor and Description |
|---|
DragHelper(int threshold)
Creates a new helper class, which may be used to measure the distance and speed of drag
gestures.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getDistance()
Deprecated.
Use
getDragDistance-method instead |
float |
getDragDistance()
Returns the distance, which has been passed while dragging, in pixels.
|
float |
getDragSpeed()
Returns the speed of the drag gesture in pixels per millisecond.
|
float |
getDragStartPosition()
Returns the position, where the drag gesture has been started at.
|
float |
getMaxDragDistance()
Returns the maximum drag distance.
|
float |
getMinDragDistance()
Returns the minimum drag distance.
|
int |
getStartPosition()
Deprecated.
Use
getDragStartPosition-method instead |
int |
getThreshold()
Returns the distance in pixels, the gesture must last until it is recognized.
|
boolean |
hasThresholdBeenReached()
Returns, whether the threshold has already been reached, or not.
|
boolean |
isReset()
Returns, whether the instance has been marked to be reset, since the method
update(float):void has been called the last time. |
boolean |
isReseted()
Deprecated.
Use
isReset-method instead |
void |
reset()
Marks the instance to be reset.
|
void |
reset(int threshold)
Marks the instance to be reset.
|
void |
setMaxDragDistance(float maxDragDistance)
Sets the maximum drag distance.
|
void |
setMinDragDistance(float minDragDistance)
Sets the minimum drag distance.
|
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 int getThreshold()
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 void reset(int threshold)
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. Furthermore, this method changes the threshold,
which is used by the instance.threshold - The distance in pixels, the gesture must last until it is recognized, as an Integer value. The value must be at least 0@Deprecated public final boolean isReseted()
isReset-method insteadupdate(float):void has been called the last time. See method
reset():void for further information.public final boolean isReset()
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 float getMaxDragDistance()
Float value or 0, if no maximum drag
distance is setpublic final void setMaxDragDistance(float maxDragDistance)
maxDragDistance - The maximum drag distance, which should be set, in pixels as a Float value or
0, if no maximum drag distance should be setpublic final float getMinDragDistance()
Float value or 0, if no minimum drag
distance is setpublic final void setMinDragDistance(float minDragDistance)
minDragDistance - The minimum drag distance, which should be set, in pixels as a Float value or
0, if no minimum drag distance should be setpublic final boolean hasThresholdBeenReached()
@Deprecated public final int getDistance()
getDragDistance-method insteadInteger value or 0,
if the threshold has not been reached yetpublic final float getDragDistance()
Float value or 0, if
the threshold has not been reached yet@Deprecated public final int getStartPosition()
getDragStartPosition-method insteadInteger value or
-1, if no gesture has been started yetpublic final float getDragStartPosition()
Float 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