belongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1
ItemTouchHelper.SimpleCallback
public
static
abstract
class
ItemTouchHelper.SimpleCallback
extends ItemTouchHelper.Callback
java.lang.Object | ||
↳ | android.support.v7.widget.helper.ItemTouchHelper.Callback | |
↳ | android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback |
A simple wrapper to the default Callback which you can construct with drag and swipe directions and this class will handle the flag callbacks. You should still override onMove or onSwiped depending on your use case.
ItemTouchHelper mIth = new ItemTouchHelper( new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT) { public abstract boolean onMove(RecyclerView recyclerView, ViewHolder viewHolder, ViewHolder target) { final int fromPos = viewHolder.getAdapterPosition(); final int toPos = target.getAdapterPosition(); // move item in `fromPos` to `toPos` in adapter. return true;// true if moved, false otherwise } public void onSwiped(ViewHolder viewHolder, int direction) { // remove from adapter } });
Summary
Inherited constants |
---|
![]()
android.support.v7.widget.helper.ItemTouchHelper.Callback
|
Public constructors | |
---|---|
ItemTouchHelper.SimpleCallback(int dragDirs, int swipeDirs)
Creates a Callback for the given drag and swipe allowance. |
Public methods | |
---|---|
int
|
getDragDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)
Returns the drag directions for the provided ViewHolder. |
int
|
getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)
Should return a composite flag which defines the enabled move directions in each state (idle, swiping, dragging). |
int
|
getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)
Returns the swipe directions for the provided ViewHolder. |
void
|
setDefaultDragDirs(int defaultDragDirs)
Updates the default drag directions. |
void
|
setDefaultSwipeDirs(int defaultSwipeDirs)
Updates the default swipe directions. |
Inherited methods | |
---|---|
![]()
android.support.v7.widget.helper.ItemTouchHelper.Callback
|