public final class EnchancedGestureDetector extends Object implements GestureDetector.OnGestureListener
MotionEvents.
The EnchancedGestureDetector.OnGestureListener callback will notify users when a particular
motion event has occurred. This class should only be used with MotionEvents
reported via touch (don't use for trackball events).
To use this class:
GestureDetector for your View
View.onTouchEvent(MotionEvent) method ensure you call
onTouchEvent(MotionEvent). The methods defined in your callback
will be executed when the events occur.
| Modifier and Type | Class and Description |
|---|---|
static interface |
EnchancedGestureDetector.OnGestureListener
The listener that is used to notify when gestures occur.
|
static class |
EnchancedGestureDetector.SimpleOnGestureListener
A convenience class to extend when you only want to listen for a subset
of all the gestures.
|
| Constructor and Description |
|---|
EnchancedGestureDetector(Context context,
EnchancedGestureDetector.OnGestureListener listener)
Creates a EnchancedGestureDetector with the supplied listener.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
onDown(MotionEvent e) |
boolean |
onFling(MotionEvent e1,
MotionEvent e2,
float velocityX,
float velocityY) |
void |
onLongPress(MotionEvent e) |
boolean |
onScroll(MotionEvent e1,
MotionEvent e2,
float distanceX,
float distanceY) |
void |
onShowPress(MotionEvent e) |
boolean |
onSingleTapUp(MotionEvent e) |
boolean |
onTouchEvent(MotionEvent e)
Analyzes the given motion event and if applicable triggers the
appropriate callbacks on the
EnchancedGestureDetector.OnGestureListener supplied. |
void |
setLongpressEnabled(boolean enabled)
Set whether longpress is enabled, if this is enabled when a user
presses and holds down you get a longpress event and nothing further.
|
public EnchancedGestureDetector(@NonNull Context context, @NonNull EnchancedGestureDetector.OnGestureListener listener)
context - the application's contextlistener - the listener invoked for all the callbacks, this must
not be null.public void setLongpressEnabled(boolean enabled)
enabled - whether longpress should be enabled.public boolean onTouchEvent(@NonNull MotionEvent e)
EnchancedGestureDetector.OnGestureListener supplied.e - The current motion event.EnchancedGestureDetector.OnGestureListener consumed the event,
else false.public boolean onDown(@NonNull MotionEvent e)
onDown in interface GestureDetector.OnGestureListenerpublic boolean onFling(@NonNull MotionEvent e1, @NonNull MotionEvent e2, float velocityX, float velocityY)
onFling in interface GestureDetector.OnGestureListenerpublic void onLongPress(@NonNull MotionEvent e)
onLongPress in interface GestureDetector.OnGestureListenerpublic boolean onScroll(@NonNull MotionEvent e1, @NonNull MotionEvent e2, float distanceX, float distanceY)
onScroll in interface GestureDetector.OnGestureListenerpublic void onShowPress(@NonNull MotionEvent e)
onShowPress in interface GestureDetector.OnGestureListenerpublic boolean onSingleTapUp(@NonNull MotionEvent e)
onSingleTapUp in interface GestureDetector.OnGestureListener