public abstract class AbstractTouchEventHandler extends java.lang.Object implements java.util.Comparator<AbstractTouchEventHandler>
TouchEventDispatcher
in order to dispatch touch events to them.Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_PRIORITY
The maximum priority of an event handler.
|
protected static int |
MIN_PRIORITY
The minimum priority of an event handler.
|
Constructor and Description |
---|
AbstractTouchEventHandler(int priority,
TabSwitcher tabSwitcher,
int dragThreshold)
Creates a new handler, which can be managed by a
TouchEventDispatcher in order to
dispatch touch events to it. |
Modifier and Type | Method and Description |
---|---|
int |
compare(AbstractTouchEventHandler o1,
AbstractTouchEventHandler o2) |
boolean |
equals(java.lang.Object obj) |
de.mrapp.android.util.gesture.DragHelper |
getDragHelper()
Returns the drag helper, which is used by the event handler to recognize drag gestures.
|
int |
getPriority()
Returns the priority of the event handler.
|
protected TabSwitcher |
getTabSwitcher()
Returns the tab switcher, the event handler belongs to.
|
android.graphics.RectF |
getTouchableArea()
Returns the bounds of the onscreen area, the handler takes into consideration for handling
touch events.
|
protected android.view.VelocityTracker |
getVelocityTracker()
The velocity tracker, which is used by the touch handler to measure the velocity of drag
gestures.
|
boolean |
handleTouchEvent(android.view.MotionEvent event)
Handles a specific touch event.
|
int |
hashCode() |
boolean |
isDragging()
Returns, whether a drag gesture is currently handled by the event handler, or not.
|
protected abstract boolean |
isDraggingAllowed()
Returns, whether performing a drag gesture is currently allowed, or not.
|
boolean |
isInsideTouchableArea(android.view.MotionEvent event)
Returns, whether a specific touch event occurred inside the touchable area of the event
handler.
|
boolean |
isReset()
Returns, whether the event handler is reset, or not.
|
protected abstract void |
onDown(android.view.MotionEvent event)
The method, which is invoked on implementing subclasses in order to handle, when a drag
gesture has been started.
|
protected abstract void |
onDrag(android.view.MotionEvent event)
The method, which is invoked on implementing subclasses in order to handle, when a drag
gesture is performed.
|
protected abstract void |
onTouchEvent()
The method, which is invoked on implementing subclasses, when a touch event is about to be
handled.
|
protected abstract void |
onUp(android.view.MotionEvent event)
Handles, when a drag gesture has been ended.
|
protected void |
reset()
Resets the event handler once a drag gesture has been ended.
|
void |
setPointerId(int pointerId)
Sets the id of the pointer, which has been used to start the current drag gesture.
|
protected static final int MAX_PRIORITY
protected static final int MIN_PRIORITY
public AbstractTouchEventHandler(int priority, @NonNull TabSwitcher tabSwitcher, int dragThreshold)
TouchEventDispatcher
in order to
dispatch touch events to it.priority
- The priority of the handler as an Integer
value. The priority must be at
least MIN_PRIORITY
and at maximum MAX_PRIORITY
tabSwitcher
- The tab switcher, the event handler belongs to, as an instance of the class TabSwitcher
. The tab switcher may not be nulldragThreshold
- The threshold of the drag helper, which is used to recognize drag gestures, in pixels
as an Integer
value The threshold must be at least 0@NonNull protected final TabSwitcher getTabSwitcher()
TabSwitcher
. The tab switcher may not be null@Nullable protected final android.view.VelocityTracker getVelocityTracker()
VelocityTracker
or null, if the velocity
tracker has not be initialized yetprotected void reset()
protected abstract boolean isDraggingAllowed()
protected abstract void onTouchEvent()
protected abstract void onDown(@NonNull android.view.MotionEvent event)
event
- The touch event, which started the drag gesture, as an instance of the class MotionEvent
. The touch event may not be nullprotected abstract void onDrag(@NonNull android.view.MotionEvent event)
event
- The last touch event of the drag gesture as an instance of the class MotionEvent
. The touch event may not be nullprotected abstract void onUp(@Nullable android.view.MotionEvent event)
event
- The touch event, which ended the drag gesture, as an instance of the class MotionEvent
or null, if no fling animation should be triggeredpublic final boolean isReset()
@CallSuper public boolean isDragging()
public final int getPriority()
Integer
value@Nullable public android.graphics.RectF getTouchableArea()
RectF
or null, if the area is not
restrictedpublic final boolean isInsideTouchableArea(@NonNull android.view.MotionEvent event)
event
- The touch event, which should be checked, as an instance of the class MotionEvent
. The touch event may not be null@NonNull public final de.mrapp.android.util.gesture.DragHelper getDragHelper()
public final void setPointerId(int pointerId)
pointerId
- The id, which should be set, as an Integer
value or -1, if no drag gesture is
currently startedpublic final boolean handleTouchEvent(@NonNull android.view.MotionEvent event)
event
- The event, which should be handled, as an instance of the class MotionEvent
.
The event may not be nullpublic final int compare(AbstractTouchEventHandler o1, AbstractTouchEventHandler o2)
compare
in interface java.util.Comparator<AbstractTouchEventHandler>
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in interface java.util.Comparator<AbstractTouchEventHandler>
equals
in class java.lang.Object