OnDragInitiatedListener
public
interface
OnDragInitiatedListener
androidx.recyclerview.selection.OnDragInitiatedListener |
Register an OnDragInitiatedListener to be notified when user intent to perform drag and drop
operations on an item or items has been detected. Handle these events using View
support for Drag and drop.
See View.startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int)
for details.
Summary
Public methods | |
---|---|
abstract
boolean
|
onDragInitiated(MotionEvent e)
Called when user intent to perform a drag and drop operation has been detected. |
Public methods
onDragInitiated
public abstract boolean onDragInitiated (MotionEvent e)
Called when user intent to perform a drag and drop operation has been detected.
The following circumstances are considered to be expressing drag and drop intent:
- Long press on selected item.
- Click and drag in the
drag region
of selected item with a pointer device. - Click and drag in drag region of un-selected item with a pointer device.
The RecyclerView item at the coordinates of the MotionEvent is not supplied as a parameter to this method as there may be multiple items selected or no items selected (as may be the case in pointer drive drag and drop.)
Obtain the current list of selected items from
SelectionTracker.copySelection(MutableSelection)
. If there is no selection
get the item under the event using ItemDetailsLookup.getItemDetails(MotionEvent)
.
Drag region used with pointer devices is specified by
ItemDetailsLookup.ItemDetails.inDragRegion(MotionEvent)
See View.startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int)
for details on drag and drop implementation.
Parameters | |
---|---|
e |
MotionEvent : the event associated with the drag. |
Returns | |
---|---|
boolean |
true if drag and drop was initiated. |