The second Android 11 Developer Preview is now available, test it out and share your feedback.

Selectable

interface Selectable
androidx.ui.core.selection.Selectable

Provides Selection information for a composable to SelectionContainer. Composables who can be selected should subscribe to SelectionRegistrar using this interface.

Summary

Public methods

abstract PxPosition
getHandlePosition(selection: Selection, isStartHandle: Boolean)

Return the PxPosition of a SelectionHandle.

abstract LayoutCoordinates?

Return the LayoutCoordinates of the Selectable.

abstract Selection?
getSelection(startPosition: PxPosition, endPosition: PxPosition, containerLayoutCoordinates: LayoutCoordinates, longPress: Boolean, previousSelection: Selection? = null, isStartHandle: Boolean = true)

Returns Selection information for a selectable composable.

Public methods

getHandlePosition

abstract fun getHandlePosition(
    selection: Selection,
    isStartHandle: Boolean
): PxPosition

Return the PxPosition of a SelectionHandle.

Parameters
selection: Selection Selection contains the SelectionHandle
isStartHandle: Boolean true if it's the start handle, false if it's the end handle.
Return
PxPosition of this handle, based on which the SelectionHandle will be drawn.

getLayoutCoordinates

abstract fun getLayoutCoordinates(): LayoutCoordinates?

Return the LayoutCoordinates of the Selectable.

Return
LayoutCoordinates of the Selectable. This could be null if called before composing.

getSelection

abstract fun getSelection(
    startPosition: PxPosition,
    endPosition: PxPosition,
    containerLayoutCoordinates: LayoutCoordinates,
    longPress: Boolean,
    previousSelection: Selection? = null,
    isStartHandle: Boolean = true
): Selection?

Returns Selection information for a selectable composable. If no selection can be provided null should be returned.

Parameters
startPosition: PxPosition graphical position of the start of the selection
endPosition: PxPosition graphical position of the end of the selection
containerLayoutCoordinates: LayoutCoordinates LayoutCoordinates of the widget
longPress: Boolean true represents that selection is either initiated via a long press or being dragged after long press
previousSelection: Selection? = null previous selection result
isStartHandle: Boolean = true true if the start handle is being dragged
Return
null if no selection will be applied for this composable, or Selection instance if selection is applied to this composable.