public class ItemDragAndSwipeCallback
extends ItemTouchHelper.Callback
| Constructor and Description |
|---|
ItemDragAndSwipeCallback(BaseItemDraggableAdapter adapter) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearView(RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder) |
int |
getMovementFlags(RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder) |
float |
getMoveThreshold(RecyclerView.ViewHolder viewHolder) |
float |
getSwipeThreshold(RecyclerView.ViewHolder viewHolder) |
boolean |
isItemViewSwipeEnabled() |
boolean |
isLongPressDragEnabled() |
void |
onChildDrawOver(android.graphics.Canvas c,
RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder,
float dX,
float dY,
int actionState,
boolean isCurrentlyActive) |
boolean |
onMove(RecyclerView recyclerView,
RecyclerView.ViewHolder source,
RecyclerView.ViewHolder target) |
void |
onMoved(RecyclerView recyclerView,
RecyclerView.ViewHolder source,
int fromPos,
RecyclerView.ViewHolder target,
int toPos,
int x,
int y) |
void |
onSelectedChanged(RecyclerView.ViewHolder viewHolder,
int actionState) |
void |
onSwiped(RecyclerView.ViewHolder viewHolder,
int direction) |
void |
setDragMoveFlags(int dragMoveFlags)
Set the drag movement direction.
|
void |
setMoveThreshold(float moveThreshold)
Set the fraction that the user should move the View to be considered as it is
dragged.
|
void |
setSwipeMoveFlags(int swipeMoveFlags)
Set the swipe movement direction.
|
void |
setSwipeThreshold(float swipeThreshold)
Set the fraction that the user should move the View to be considered as swiped.
|
public ItemDragAndSwipeCallback(BaseItemDraggableAdapter adapter)
public boolean isLongPressDragEnabled()
public boolean isItemViewSwipeEnabled()
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,
int actionState)
public void clearView(RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder)
public int getMovementFlags(RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder)
public boolean onMove(RecyclerView recyclerView,
RecyclerView.ViewHolder source,
RecyclerView.ViewHolder target)
public void onMoved(RecyclerView recyclerView,
RecyclerView.ViewHolder source,
int fromPos,
RecyclerView.ViewHolder target,
int toPos,
int x,
int y)
public void onSwiped(RecyclerView.ViewHolder viewHolder,
int direction)
public float getMoveThreshold(RecyclerView.ViewHolder viewHolder)
public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder)
public void setSwipeThreshold(float swipeThreshold)
Default value is .5f, which means, to swipe a View, user must move the View at least half of RecyclerView's width or height, depending on the swipe direction.
swipeThreshold - A float value that denotes the fraction of the View size. Default value
is .8f .public void setMoveThreshold(float moveThreshold)
moveThreshold - A float value that denotes the fraction of the View size. Default value is
.1f .public void setDragMoveFlags(int dragMoveFlags)
Set the drag movement direction.
The value should be ItemTouchHelper.UP, ItemTouchHelper.DOWN, ItemTouchHelper.LEFT, ItemTouchHelper.RIGHT or their combination.
You can combine them like ItemTouchHelper.UP | ItemTouchHelper.DOWN, it means that the item could only move up and down when dragged.dragMoveFlags - the drag movement direction. Default value is ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT.public void setSwipeMoveFlags(int swipeMoveFlags)
Set the swipe movement direction.
The value should be ItemTouchHelper.START, ItemTouchHelper.END or their combination.
You can combine them like ItemTouchHelper.START | ItemTouchHelper.END, it means that the item could swipe to both left or right.swipeMoveFlags - the swipe movement direction. Default value is ItemTouchHelper.END.public void onChildDrawOver(android.graphics.Canvas c,
RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder,
float dX,
float dY,
int actionState,
boolean isCurrentlyActive)