public class TouchEventDispatcher extends java.lang.Object implements java.lang.Iterable<AbstractTouchEventHandler>
Modifier and Type | Class and Description |
---|---|
static interface |
TouchEventDispatcher.Callback
Defines the interface, a class, which should be notified, when event handlers are added to or
removed from a
TouchEventDispatcher , must implement. |
Constructor and Description |
---|
TouchEventDispatcher()
Creates a new dispatcher, which allows to dispatch touch events to multiple event handlers in
the order of their priority.
|
Modifier and Type | Method and Description |
---|---|
void |
addEventHandler(AbstractTouchEventHandler handler)
Adds a specific event handler to the dispatcher.
|
boolean |
handleTouchEvent(android.view.MotionEvent event)
Handles a specific touch event by dispatching it to the first suited event handler.
|
java.util.Iterator<AbstractTouchEventHandler> |
iterator() |
void |
removeEventHandler(AbstractTouchEventHandler handler)
Removes a specific event handler from the dispatcher.
|
void |
setCallback(TouchEventDispatcher.Callback callback)
Sets the callback, which should be notified, when event handlers are added or removed.
|
public TouchEventDispatcher()
public final void setCallback(@Nullable TouchEventDispatcher.Callback callback)
callback
- The callback, which should be set, as an instance of the type TouchEventDispatcher.Callback
or
null, if no callback should be notifiedpublic final void addEventHandler(@NonNull AbstractTouchEventHandler handler)
handler
- The event handler, which should be added, as an instance of hte class AbstractTouchEventHandler
. The event handler may not be nullpublic final void removeEventHandler(@NonNull AbstractTouchEventHandler handler)
handler
- The event handler, which should be removed, as an instance of the class AbstractTouchEventHandler
. The event handler may not be nullpublic 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 java.util.Iterator<AbstractTouchEventHandler> iterator()
iterator
in interface java.lang.Iterable<AbstractTouchEventHandler>