-
public class DragAndSwipeCallback extends ItemTouchHelper.Callback
-
-
Constructor Summary
Constructors Constructor Description DragAndSwipeCallback(BaseDraggableModule draggableModule)
-
Method Summary
Modifier and Type Method Description booleanisLongPressDragEnabled()booleanisItemViewSwipeEnabled()voidonSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState)voidclearView(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder viewHolder)intgetMovementFlags(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder viewHolder)booleanonMove(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder source, @NonNull() RecyclerView.ViewHolder target)voidonMoved(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder source, int fromPos, @NonNull() RecyclerView.ViewHolder target, int toPos, int x, int y)voidonSwiped(@NonNull() RecyclerView.ViewHolder viewHolder, int direction)floatgetMoveThreshold(@NonNull() RecyclerView.ViewHolder viewHolder)floatgetSwipeThreshold(@NonNull() RecyclerView.ViewHolder viewHolder)voidsetSwipeThreshold(float swipeThreshold)Set the fraction that the user should move the View to be considered as swiped.The fraction is calculated with respect to RecyclerView's bounds. voidsetMoveThreshold(float moveThreshold)Set the fraction that the user should move the View to be considered as it isdragged. voidsetDragMoveFlags(int dragMoveFlags)Set the drag movement direction. voidsetSwipeMoveFlags(int swipeMoveFlags)Set the swipe movement direction. voidonChildDrawOver(@NonNull() Canvas c, @NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive)-
Methods inherited from class androidx.recyclerview.widget.ItemTouchHelper.Callback
canDropOver, chooseDropTarget, clearView, convertToAbsoluteDirection, convertToRelativeDirection, getAnimationDuration, getBoundingBoxMargin, getDefaultUIUtil, getMoveThreshold, getMovementFlags, getSwipeEscapeVelocity, getSwipeThreshold, getSwipeVelocityThreshold, interpolateOutOfBoundsScroll, isItemViewSwipeEnabled, isLongPressDragEnabled, makeFlag, makeMovementFlags, onChildDraw, onChildDrawOver, onMove, onMoved, onSelectedChanged, onSwiped -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
DragAndSwipeCallback
DragAndSwipeCallback(BaseDraggableModule draggableModule)
-
-
Method Detail
-
isLongPressDragEnabled
boolean isLongPressDragEnabled()
-
isItemViewSwipeEnabled
boolean isItemViewSwipeEnabled()
-
onSelectedChanged
void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState)
-
clearView
void clearView(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder viewHolder)
-
getMovementFlags
int getMovementFlags(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder viewHolder)
-
onMove
boolean onMove(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder source, @NonNull() RecyclerView.ViewHolder target)
-
onMoved
void onMoved(@NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder source, int fromPos, @NonNull() RecyclerView.ViewHolder target, int toPos, int x, int y)
-
onSwiped
void onSwiped(@NonNull() RecyclerView.ViewHolder viewHolder, int direction)
-
getMoveThreshold
float getMoveThreshold(@NonNull() RecyclerView.ViewHolder viewHolder)
-
getSwipeThreshold
float getSwipeThreshold(@NonNull() RecyclerView.ViewHolder viewHolder)
-
setSwipeThreshold
void setSwipeThreshold(float swipeThreshold)
Set the fraction that the user should move the View to be considered as swiped.The fraction is calculated with respect to RecyclerView's bounds.
Default value is .5f, which means, to swipe a View, user must move the View at leasthalf of RecyclerView's width or height, depending on the swipe direction.
- Parameters:
swipeThreshold- A float value that denotes the fraction of the View size.
-
setMoveThreshold
void setMoveThreshold(float moveThreshold)
Set the fraction that the user should move the View to be considered as it isdragged. After a view is moved this amount, ItemTouchHelper starts checking for Viewsbelow it for a possible drop.
- Parameters:
moveThreshold- A float value that denotes the fraction of the View size.
-
setDragMoveFlags
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.- Parameters:
dragMoveFlags- the drag movement direction.
-
setSwipeMoveFlags
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.- Parameters:
swipeMoveFlags- the swipe movement direction.
-
onChildDrawOver
void onChildDrawOver(@NonNull() Canvas c, @NonNull() RecyclerView recyclerView, @NonNull() RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive)
-
-
-
-