-
- All Implemented Interfaces:
-
com.airbnb.epoxy.BaseEpoxyTouchCallback,com.airbnb.epoxy.EpoxySwipeCallback
public abstract class EpoxyTouchHelper.SwipeCallbacks<T extends EpoxyModel> implements EpoxySwipeCallback<T>
-
-
Method Summary
Modifier and Type Method Description voidonSwipeStarted(T model, View itemView, int adapterPosition)Called when the view switches from an idle state to a swiped state, as the user begins a swipeinteraction with it. voidonSwipeProgressChanged(T model, View itemView, float swipeProgress, Canvas canvas)Once a view has begun swiping with onSwipeStarted it willreceive this callback as the swipe distance changes. abstract voidonSwipeCompleted(T model, View itemView, int position, int direction)Called after onSwipeReleased if the swipe surpassed the threshold tobe considered a full swipe. voidonSwipeReleased(T model, View itemView)Called when the user has released their touch on the view. voidclearView(T model, View itemView)Called when the user interaction with a view is over and the view hascompleted its animation. booleanisSwipeEnabledForModel(T model)Whether the given model should be swipable. 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
-
onSwipeStarted
void onSwipeStarted(T model, View itemView, int adapterPosition)
Called when the view switches from an idle state to a swiped state, as the user begins a swipeinteraction with it. You can use this callback to modify the view to indicate it is beingswiped.
This is the first callback made in the lifecycle of a swipe event.
- Parameters:
model- The model representing the view that is being swipeditemView- The view that is being swipedadapterPosition- The adapter position of the model
-
onSwipeProgressChanged
void onSwipeProgressChanged(T model, View itemView, float swipeProgress, Canvas canvas)
Once a view has begun swiping with onSwipeStarted it willreceive this callback as the swipe distance changes. This can be called multiple times as theswipe interaction progresses.
- Parameters:
model- The model representing the view that is being swipeditemView- The view that is being swipedswipeProgress- A float from -1 to 1 representing the percentage that the view has beenswiped relative to its width.canvas- The canvas on which RecyclerView is drawing its children.
-
onSwipeCompleted
abstract void onSwipeCompleted(T model, View itemView, int position, int direction)
Called after onSwipeReleased if the swipe surpassed the threshold tobe considered a full swipe. The view will now be animated off screen.
You MUST use this callback to remove this item from your backing data and request a modelupdate.
clearView will be called after this.
- Parameters:
model- The model representing the view that was being swipeditemView- The view that was being swipedposition- The adapter position of the modeldirection- The direction that the view was swiped.
-
onSwipeReleased
void onSwipeReleased(T model, View itemView)
Called when the user has released their touch on the view. If the displacement passed the swipethreshold then onSwipeCompleted will be called after thisand the view will be animated off screen. Otherwise the view will animate back to its originalposition.
- Parameters:
model- The model representing the view that was being swipeditemView- The view that was being swiped
-
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.
-
isSwipeEnabledForModel
boolean isSwipeEnabledForModel(T model)
Whether the given model should be swipable.
True by default. You may override this to toggle swipabaility 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
-
-
-
-