drags

fun View.drags(handled: (DragEvent) -> Boolean = { true }): Flow<DragEvent>

Create a Flow of drag events on the View instance.

Parameters

handled

function to be invoked with each value to determine the return value of the underlying View.OnDragListener. Note that the Flow will only emit when this function evaluates to true.

Note: Created flow keeps a strong reference to the View instance until the coroutine that launched the flow collector is cancelled.

Example of usage:

view.drags { it.action == DragEvent.ACTION_DRAG_ENDED }
.onEach { event ->
// handle drag event
}
.launchIn(uiScope)