itemLongClicks

fun <T : Adapter> AdapterView<T>.itemLongClicks(handled: () -> Boolean = { true }): Flow<Int>

Create a Flow of item long clicks on the AdapterView instance where the value emitted is the position of the item clicked.

Parameters

handled

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

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

Example of usage:

adapterView.itemLongClicks { it.position == 0 }
.onEach { position ->
// handle adapter view item long clicked
}
.launchIn(uiScope)