DpadDragHelper

class DpadDragHelper<T>(adapter: DpadDragHelper.DragAdapter<T>, callback: DpadDragHelper.DragCallback, stopKeyCodes: Set<Int> = setOf( KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER, ))

A helper class for re-ordering the contents of a DpadRecyclerView.

To use this, your adapter needs to implement DpadDragHelper.DragAdapter and expose the mutable collection via DpadDragHelper.DragAdapter.getMutableItems.

Parameters

adapter

the adapter that backs the data that can be arranged

callback

the callback for notifying dragging state changes

stopKeyCodes

key codes that will be accepted to stop the dragging state

Constructors

Link copied to clipboard
constructor(adapter: DpadDragHelper.DragAdapter<T>, callback: DpadDragHelper.DragCallback, stopKeyCodes: Set<Int> = setOf( KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER, ))

Types

Link copied to clipboard
interface DragAdapter<T>
Link copied to clipboard
interface DragCallback

Properties

Link copied to clipboard

True if the attached DpadRecyclerView is currently in drag mode, false otherwise

Functions

Link copied to clipboard

Attaches the DpadRecyclerView that will be dragged. This is required before calling startDrag

Link copied to clipboard

Detaches the previously attached DpadRecyclerView and stops dragging

Link copied to clipboard
fun startDrag(position: Int): Boolean

Starts the dragging action for the ViewHolder at position.

Link copied to clipboard
fun stopDrag()

Cancels the current ongoing dragging action DragCallback.onDragStopped will be called after this method