-
public interface ItemTouchHelperCallback.AdapterCallbackInternal interface for Adapter to listen for a move or swipe dismissal eventfrom a ItemTouchHelperCallback.
-
-
Method Summary
Modifier and Type Method Description abstract voidonActionStateChanged(RecyclerView.ViewHolder viewHolder, int actionState)Called when the ItemTouchHelper first registers an item as being moved or swipedor when has been released. abstract booleanshouldMove(int fromPosition, int toPosition)Evaluate if positions are compatible for swapping. abstract booleanonItemMove(int fromPosition, int toPosition)Called when an item has been dragged far enough to trigger a move. abstract voidonItemSwiped(int position, int direction)Called when an item has been dismissed by a swipe. -
-
Method Detail
-
onActionStateChanged
abstract void onActionStateChanged(RecyclerView.ViewHolder viewHolder, int actionState)
Called when the ItemTouchHelper first registers an item as being moved or swipedor when has been released.
Override this method to receive touch events with its state.
- Parameters:
viewHolder- the viewHolder touchedactionState- one of ACTION_STATE_SWIPE orACTION_STATE_DRAG orACTION_STATE_IDLE.
-
shouldMove
abstract boolean shouldMove(int fromPosition, int toPosition)
Evaluate if positions are compatible for swapping.
- Parameters:
fromPosition- the start position of the moving itemtoPosition- the potential target position of the moving item
-
onItemMove
abstract boolean onItemMove(int fromPosition, int toPosition)
Called when an item has been dragged far enough to trigger a move. This is calledevery time an item is shifted, and not at the end of a "drop" event.
Implementations should call notifyItemMoved after adjusting the underlying data to reflect this move.
- Parameters:
fromPosition- the start position of the moved itemtoPosition- the resolved position of the moved item
-
onItemSwiped
abstract void onItemSwiped(int position, int direction)
Called when an item has been dismissed by a swipe.
Implementations should decide to call or not notifyItemRemoved after adjusting the underlying data to reflect this removal.
- Parameters:
position- the position of the item dismisseddirection- the direction to which the ViewHolder is swiped
-
-
-
-