Skip to content

//workflow/com.squareup.workflow1.ui/getFactoryForRendering

getFactoryForRendering

[androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> ViewRegistry.getFactoryForRendering(rendering: RenderingT): ViewFactory<RenderingT>
More info

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

Returns the ViewFactory that builds View instances suitable to display the given rendering, via subsequent calls to View.showRendering.

Prefers factories found via ViewRegistry.getFactoryFor. If that returns null, falls back to the factory provided by the rendering’s implementation of AndroidViewRendering.viewFactory, if there is one. Note that this means that a compile time AndroidViewRendering.viewFactory binding can be overridden at runtime.

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.

Throws

kotlin.IllegalArgumentException

if no factory can be find for type RenderingT