Skip to content

//workflow/com.squareup.workflow1.ui/buildView

buildView

[androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> ViewRegistry.buildView(initialRendering: RenderingT, initialViewEnvironment: ViewEnvironment, contextForNewView: Context, container: ViewGroup? = null, initializeView: View.() -> Unit = { showFirstRendering() }): View
More info

It is usually more convenient to use WorkflowViewStub or DecorativeViewFactory than to call this method directly.

Finds a ViewFactory to create a View to display initialRendering. The new view can be updated via calls to View.showRendering – that is, it is guaranteed that bindShowRendering has been called on this view.

The returned view will have a WorkflowLifecycleOwner set on it. The returned view must EITHER:

  1. Be attached at least once to ensure that the lifecycle eventually gets destroyed (because its parent is destroyed), or
  2. Have its [WorkflowLifecycleOwner.destroyOnDetach](../com.squareup.workflow1.ui.androidx/-workflow-lifecycle-owner/destroy-on-detach.md) called, which will either schedule the lifecycle to be destroyed if the view is attached, or destroy it immediately if it's detached.

Parameters

androidJvm

initializeView

Optional function invoked immediately after the View is created (that is, immediately after the call to ViewFactory.buildView). showRendering, getRendering and environment are all available when this is called. Defaults to a call to View.showFirstRendering.

Throws

kotlin.IllegalArgumentException

if no factory can be find for type RenderingT

kotlin.IllegalStateException

if the matching ViewFactory fails to call View.bindShowRendering when constructing the view