InflateViewFactory

class InflateViewFactory<T, B : ViewDataBinding>(inflateFunction: (LayoutInflater, container: ViewGroup?, attachToContainer: Boolean) -> B, bindViewModelVariable: Boolean = true, bindDataFunction: (B, T) -> Unit? = null) : ViewFactory<T>

A ViewFactory for inflating layouts that uses generated data binding of type B and binds data to the view of type T.

See also the invoke operator to create a ViewFactory that inflates a layout identified by a layout ID.

Parameters

inflateFunction

A function that will inflate a view given a layout inflater, a parent view, and whether the view should be attached to the parent upon inflation. Matches the signature of a generated data binding class's inflate.

bindViewModelVariable

If true, if the view has a viewModel data binding variable and its type matches with T, the data given to bind is set to the variable.

bindDataFunction

A function that will be called after view inflation, and can be used to bind data to the view.

Constructors

Link copied to clipboard
constructor(inflateFunction: (LayoutInflater, container: ViewGroup?, attachToContainer: Boolean) -> B, bindViewModelVariable: Boolean = true, bindDataFunction: (B, T) -> Unit? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun bind(view: View, data: T, viewLifecycleOwner: LifecycleOwner)

Binds the given view to data and the given viewLifecycleOwner.

Link copied to clipboard
open override fun createView(context: Context, parent: ViewGroup?, attachToParent: Boolean): View

Creates a view.

Link copied to clipboard
open override fun rebind(view: View, data: T)

Rebinds the given view to data.