ViewProvider

class ViewProvider<VM>(lifecycleOwner: LifecycleOwner, layoutProvider: LayoutProvider<VM>)

Provides a view for a view model. To do so, it uses the layoutProvider to get a layout ID for the view model. It then inflates this and creates a ViewDataBinding and sets the lifecycleOwner to it.

Also, if the bindings from the layoutProvider provide a viewModel data binding variable with a matching type, the ViewModel instance is set as value of the data binding variable. It is not mandatory to have a viewModel data binding variable.

Constructors

Link copied to clipboard
constructor(lifecycleOwner: LifecycleOwner, layoutId: Int)

Convenience constructor to create a view provider that provides the same layout ID for all view models.

constructor(lifecycleOwner: LifecycleOwner, layoutProvider: LayoutProvider<VM>)