Doug McCluer
02/13/2021, 5:00 PMDoug McCluer
02/13/2021, 5:29 PMRay Ryan
02/13/2021, 6:36 PMDoug McCluer
02/13/2021, 6:45 PM@OptIn(WorkflowUiExperimentalApi::class)
class DiscoverViewFactory(val imageLoader:IImageLoader):ViewFactory<DiscoverRendering> {
override val type = DiscoverRendering::class
override fun buildView(
initialRendering:DiscoverRendering,
initialViewEnvironment:ViewEnvironment,
contextForNewView:Context,
container:ViewGroup?
):View {
return DiscoverView(
imageLoader = imageLoader,
context = contextForNewView
)
}
}
and put an instance of that in the viewRegistry, I'm getting an error saying that bindShowRendering
was not calledDoug McCluer
02/13/2021, 6:47 PMbindShowRendering
exactly?Ray Ryan
02/13/2021, 6:48 PMRay Ryan
02/13/2021, 6:54 PMimport com.squareup.workflow1.ui.bindShowRendering
return DiscoverView(
imageLoader = imageLoader,
context = contextForNewView
).apply {
bindShowRendering(initialRendering, initialEnv, ::update)
}
Where update
is whatever function your view defines to receive fresh instances of the rendering.Ray Ryan
02/13/2021, 6:54 PMDoug McCluer
02/13/2021, 6:54 PM(RenderingT, ViewEnvironment) -> Unit
and have the factory do something like
@OptIn(WorkflowUiExperimentalApi::class)
class DiscoverViewFactory(val imageLoader:IImageLoader):ViewFactory<DiscoverRendering> {
override val type = DiscoverRendering::class
override fun buildView(
initialRendering:DiscoverRendering,
initialViewEnvironment:ViewEnvironment,
contextForNewView:Context,
container:ViewGroup?
):View {
return DiscoverView(
imageLoader = imageLoader,
context = contextForNewView
).apply {
bindShowRendering(initialRendering, initialViewEnvironment){ ren:DiscoverRendering, env:ViewEnvironment ->
showRendering(ren, env)
}
}
}
}
?Ray Ryan
02/13/2021, 6:55 PMDoug McCluer
02/13/2021, 6:56 PMRay Ryan
02/13/2021, 6:56 PMRay Ryan
02/13/2021, 6:56 PMlayoutParams = LayoutParams(MATCH_PARENT, MATCH_PARENT)
Doug McCluer
02/13/2021, 6:56 PMRay Ryan
02/13/2021, 6:57 PMDoug McCluer
02/13/2021, 6:59 PM