DpadComposeFocusViewHolder

class DpadComposeFocusViewHolder<T>(parent: ViewGroup, isFocusable: Boolean = true, content: @Composable (item: T) -> Unit? = null) : RecyclerView.ViewHolder

This allows inline definition of ViewHolders in onCreateViewHolder:

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DpadComposeFocusViewHolder<Int> {
return DpadComposeFocusViewHolder(parent) { item ->
ItemComposable(item)
}
}

To update the current item, override onBindViewHolder and call setItemState:

override fun onBindViewHolder(holder: DpadComposeFocusViewHolder<Int>, position: Int) {
holder.setItemState(getItem(position))
}

Constructors

Link copied to clipboard
constructor(parent: ViewGroup, isFocusable: Boolean = true, content: @Composable (item: T) -> Unit? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun getItem(): T?
Link copied to clipboard
fun setContent(content: @Composable (item: T) -> Unit)

Sets the content of the internal ComposeView

Link copied to clipboard
fun setFocusable(focusable: Boolean)

Marks the internal ComposeView has focusable or not. If false, this will prevent child nodes from being focusable

Link copied to clipboard
fun setIsRecyclable(recyclable: Boolean)
Link copied to clipboard
fun setItemState(item: T?)

Updates the current item so that the composition is updated with the new value in content