CallbackType
- The type of the drag handler's callbackpublic abstract class AbstractDragTabsEventHandler<CallbackType extends AbstractDragTabsEventHandler.Callback> extends AbstractTouchEventHandler
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractDragTabsEventHandler.Callback
Defines the interface, a class, which should be notified about the events of a drag handler,
must implement.
|
static class |
AbstractDragTabsEventHandler.DragState
Contains all possible states of dragging gestures, which can be performed on a
TabSwitcher . |
MAX_PRIORITY, MIN_PRIORITY
Constructor and Description |
---|
AbstractDragTabsEventHandler(TabSwitcher tabSwitcher,
Arithmetics arithmetics,
boolean swipeEnabled)
Creates a new drag handler, which allows to calculate the position and state of tabs on touch
events.
|
Modifier and Type | Method and Description |
---|---|
protected Arithmetics |
getArithmetics()
Returns the arithmetics, which are used to calculate the positions, size and rotation of
tabs.
|
protected CallbackType |
getCallback()
Returns the callback, which should be notified about the drag handler's events.
|
protected abstract AbstractItem |
getFocusedItem(float position)
The method, which is invoked on implementing subclasses in order to retrieve the item, which
corresponds to the view, which is focused when clicking/dragging at a specific position.
|
boolean |
handleDrag(float dragPosition,
float orthogonalPosition)
Handles drag gestures.
|
boolean |
isDragging()
Returns, whether a drag gesture is currently handled by the event handler, or not.
|
protected boolean |
isDraggingAllowed()
Returns, whether performing a drag gesture is currently allowed, or not.
|
protected boolean |
isSwipeThresholdReached(TabItem swipedTabItem)
Returns, whether the threshold of a swiped tab item, which causes the corresponding tab to be
removed, has been reached, or not.
|
protected 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 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 float |
onOvershootEnd(float dragPosition,
float overshootThreshold)
The method, which is invoked on implementing subclasses, when the tabs are overshooting at
the end.
|
protected void |
onOvershootReverted()
The method, which is invoked on implementing subclasses, when an overshoot has been reverted.
|
protected float |
onOvershootStart(float dragPosition,
float overshootThreshold)
The method, which is invoked on implementing subclasses, when the tabs are overshooting at
the start.
|
protected void |
onReset()
The method, which invoked on implementing subclasses, when the drag handler has been reset.
|
protected void |
onTouchEvent()
The method, which is invoked on implementing subclasses, when a touch event is about to be
handled.
|
void |
onUp(android.view.MotionEvent event)
Handles, when a drag gesture has been ended.
|
void |
reset()
Resets the event handler once a drag gesture has been ended.
|
void |
setCallback(CallbackType callback)
Sets the callback, which should be notified about the drag handler's events.
|
void |
setDragState(AbstractDragTabsEventHandler.DragState dragState)
Sets the state of the currently performed drag gesture.
|
compare, equals, getDragHelper, getPriority, getTabSwitcher, getTouchableArea, getVelocityTracker, handleTouchEvent, hashCode, isInsideTouchableArea, isReset, setPointerId
public AbstractDragTabsEventHandler(@NonNull TabSwitcher tabSwitcher, @NonNull Arithmetics arithmetics, boolean swipeEnabled)
tabSwitcher
- The tab switcher, whose tabs' positions and states should be calculated by the drag
handler, as an instance of the class TabSwitcher
. The tab switcher may not be
nullarithmetics
- The arithmetics, which should be used to calculate the position, size and rotation of
tabs, as an instance of the type Arithmetics
. The arithmetics may not be
nullswipeEnabled
- True, if tabs can be swiped on the orthogonal axis, false otherwise@NonNull protected Arithmetics getArithmetics()
Arithmetics
. The arithmetics may not be null@Nullable protected CallbackType getCallback()
protected abstract AbstractItem getFocusedItem(float position)
position
- The position on the dragging axis in pixels as a Float
valueAbstractItem
or null, if no view is focusedprotected float onOvershootStart(float dragPosition, float overshootThreshold)
dragPosition
- The position of the pointer on the dragging axis in pixels as a Float
valueovershootThreshold
- The position on the dragging axis, an overshoot at the start currently starts at, in
pixels as a Float
valueFloat
valueprotected float onOvershootEnd(float dragPosition, float overshootThreshold)
dragPosition
- The position of the pointer on the dragging axis in pixels as a Float
valueovershootThreshold
- The position on the dragging axis, an overshoot at the end currently starts at, in
pixels as a Float
valueFloat
valueprotected void onOvershootReverted()
protected void onReset()
protected boolean isSwipeThresholdReached(@NonNull TabItem swipedTabItem)
swipedTabItem
- The swiped tab item as an instance of the class TabItem
. The tab item may not
be nullpublic final void setCallback(@Nullable CallbackType callback)
callback
- The callback, which should be set, as an instance of the generic type CallbackType or
null, if no callback should be notifiedpublic final void setDragState(@NonNull AbstractDragTabsEventHandler.DragState dragState)
dragState
- The state, which should be set, as a value of the enum AbstractDragTabsEventHandler.DragState
. The state
may not be nullpublic final boolean handleDrag(float dragPosition, float orthogonalPosition)
dragPosition
- The position of the pointer on the dragging axis in pixels as a Float
valueorthogonalPosition
- The position of the pointer of the orthogonal axis in pixels as a Float
valuepublic final boolean isDragging()
AbstractTouchEventHandler
isDragging
in class AbstractTouchEventHandler
public final void reset()
AbstractTouchEventHandler
reset
in class AbstractTouchEventHandler
protected final boolean isDraggingAllowed()
AbstractTouchEventHandler
isDraggingAllowed
in class AbstractTouchEventHandler
protected final void onTouchEvent()
AbstractTouchEventHandler
onTouchEvent
in class AbstractTouchEventHandler
protected final void onDown(@NonNull android.view.MotionEvent event)
AbstractTouchEventHandler
onDown
in class AbstractTouchEventHandler
event
- The touch event, which started the drag gesture, as an instance of the class MotionEvent
. The touch event may not be nullprotected final void onDrag(@NonNull android.view.MotionEvent event)
AbstractTouchEventHandler
onDrag
in class AbstractTouchEventHandler
event
- The last touch event of the drag gesture as an instance of the class MotionEvent
. The touch event may not be nullpublic final void onUp(@Nullable android.view.MotionEvent event)
AbstractTouchEventHandler
onUp
in class AbstractTouchEventHandler
event
- The touch event, which ended the drag gesture, as an instance of the class MotionEvent
or null, if no fling animation should be triggered