-
- All Implemented Interfaces:
-
com.airbnb.epoxy.BaseEpoxyTouchCallback,com.airbnb.epoxy.EpoxyDragCallback
public abstract class EpoxyTouchHelper.DragCallbacks<T extends EpoxyModel> implements EpoxyDragCallback<T>
-
-
Method Summary
Modifier and Type Method Description voidonDragStarted(T model, View itemView, int adapterPosition)Called when the view switches from an idle state to a dragged state, as the user begins a draginteraction with it. voidonDragReleased(T model, View itemView)Called after onDragStarted when the view being dragged isreleased. abstract voidonModelMoved(int fromPosition, int toPosition, T modelBeingMoved, View itemView)Called after onDragStarted when the dragged view is dropped toa new position. voidclearView(T model, View itemView)Called when the user interaction with a view is over and the view hascompleted its animation. booleanisDragEnabledForModel(T model)Whether the given model should be draggable. final intgetMovementFlagsForModel(T model, int adapterPosition)Should return a composite flag which defines the enabled move directions in each state(idle, swiping, dragging) for the given model. -
-
Method Detail
-
onDragStarted
void onDragStarted(T model, View itemView, int adapterPosition)
Called when the view switches from an idle state to a dragged state, as the user begins a draginteraction with it. You can use this callback to modify the view to indicate it is beingdragged.
This is the first callback in the lifecycle of a drag event.
- Parameters:
model- The model representing the view that is being draggeditemView- The view that is being draggedadapterPosition- The adapter position of the model
-
onDragReleased
void onDragReleased(T model, View itemView)
Called after onDragStarted when the view being dragged isreleased. If the view was dragged to a new, valid location then onModelMoved will be called before this and the view will settle to the new location.Otherwise the view will animate back to its original position.
You can use this callback to modify the view as it animates back into position.
clearView will be called after this, when theview has finished animating. Final cleanup of the view should be done there.
- Parameters:
model- The model representing the view that is being releaseditemView- The view that was being dragged
-
onModelMoved
abstract void onModelMoved(int fromPosition, int toPosition, T modelBeingMoved, View itemView)
Called after onDragStarted when the dragged view is dropped toa new position. The EpoxyController will be updated automatically for you to reposition themodels and notify the RecyclerView of the change.
You MUST use this callback to modify your data backing the models to reflect the change.
The next callback in the drag lifecycle will be onDragStarted
- Parameters:
fromPosition- The adapter position that the model came fromtoPosition- The new adapter position of the modelmodelBeingMoved- The model representing the view that was moveditemView- The view that was moved
-
clearView
void clearView(T model, View itemView)
Called when the user interaction with a view is over and the view hascompleted its animation. This is a good place to clear all changes on the view that were donein other previous touch callbacks (such as on touch start, change, release, etc).
This is the last callback in the lifecycle of a touch event.
- Parameters:
model- The model whose view is being cleared.itemView- The view being cleared.
-
isDragEnabledForModel
boolean isDragEnabledForModel(T model)
Whether the given model should be draggable.
True by default. You may override this to toggle draggability for a model.
-
getMovementFlagsForModel
final int getMovementFlagsForModel(T model, int adapterPosition)
Should return a composite flag which defines the enabled move directions in each state(idle, swiping, dragging) for the given model.
Return 0 to disable movement for the model.
- Parameters:
model- The model being targeted for movement.adapterPosition- The current adapter position of the targeted model
-
-
-
-