DpadComposeFocusViewHolder

class DpadComposeFocusViewHolder<T>(parent: ViewGroup, compositionStrategy: ViewCompositionStrategy = RecyclerViewCompositionStrategy.DisposeOnRecycled, isFocusable: Boolean = true, content: @Composable (item: T) -> Unit = {}) : RecyclerView.ViewHolder

Similar to DpadComposeViewHolder, but sends the focus down to composables

This allows inline definition of ViewHolders in onCreateViewHolder:

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

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, compositionStrategy: ViewCompositionStrategy = RecyclerViewCompositionStrategy.DisposeOnRecycled, isFocusable: Boolean = true, content: @Composable (item: T) -> Unit = {})

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getItem(): T?
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
fun setContent(content: @Composable (item: T) -> Unit)
Link copied to clipboard
fun setFocusable(focusable: Boolean)
Link copied to clipboard
Link copied to clipboard
fun setItemState(item: T?)
Link copied to clipboard
open override fun toString(): String