BindingViewFactory

class BindingViewFactory<B : ViewDataBinding>(inflateFunction: (LayoutInflater) -> B, bindDataFunction: (B) -> Unit) : SystemUiHost.ViewFactory

A factory for a data-bound main view to be shown within the system UI which that takes care of common tasks around inflation and binding a lifecycle owner.

If the binding accepts a panelContainerViewContext property of type PanelContainerViewContext, a value will automatically be assigned to it. If the binding doesn't have such a property or has to bind additional data, bindDataFunction can be used to do so.

Parameters

inflateFunction

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

bindDataFunction

A function that will be called after view inflation, and can be used to bind data to the view. Pending bindings left after this function is called will be immediately executed.

Constructors

Link copied to clipboard
fun <B : ViewDataBinding> BindingViewFactory(inflateFunction: (LayoutInflater) -> B, bindDataFunction: (B) -> Unit)

Functions

Link copied to clipboard
open override fun bindData(lifecycleOwner: LifecycleOwner, panelContainerViewContext: PanelContainerViewContext)

Binds a view that was previously inflated with inflate to its data, observed by the given LifecycleOwner. The provided panelContainerViewContext can be used for binding panels to PanelContainerViews.

Link copied to clipboard
open override fun inflate(inflater: LayoutInflater): View

Inflates the view using the given inflater. The view will should not be attached to the container, but will be attached by the system UI.