Skip to content

Commit 78b74ec

Browse files
committed
One more pass at the ScreenViewFactory kdoc
Emphasizing that WorkflowViewStub is the right thing, and that ScreenViewRunner is the strategy object that feature developers implement.
1 parent 8c17fb5 commit 78b74ec

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/ScreenViewFactory.kt

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.annotation.LayoutRes
88
import androidx.viewbinding.ViewBinding
99
import com.squareup.workflow1.ui.ScreenViewFactory.Companion.forBuiltView
1010
import com.squareup.workflow1.ui.ScreenViewFactory.Companion.forLayoutResource
11-
import com.squareup.workflow1.ui.ScreenViewFactory.Companion.forStaticLayoutResource
1211
import com.squareup.workflow1.ui.ScreenViewFactory.Companion.forViewBinding
1312

1413
@WorkflowUiExperimentalApi
@@ -19,10 +18,11 @@ public typealias ViewBindingInflater<BindingT> = (LayoutInflater, ViewGroup?, Bo
1918
* Each [ScreenViewRunner] instance is paired with the single [View] instance,
2019
* its neighbor in a [ScreenViewHolder].
2120
*
22-
* Use [forLayoutResource], [forViewBinding], etc., to create a [ScreenViewFactory].
23-
* These helper methods take a layout resource, view binding, or view building
24-
* function as arguments, along with a factory to create a [showRendering]
25-
* [ScreenViewRunner.showRendering] function.
21+
* This is the interface you'll implement directly to update Android view code
22+
* from your [Screen] renderings. A [ScreenViewRunner] serves as the strategy
23+
* object of a [ScreenViewHolder] instantiated by a [ScreenViewFactory] -- the
24+
* runner provides the implmenetation for the holder's [ScreenViewHolder.show]
25+
* method.
2626
*/
2727
@WorkflowUiExperimentalApi
2828
public fun interface ScreenViewRunner<in ScreenT : Screen> {
@@ -37,20 +37,28 @@ public fun interface ScreenViewRunner<in ScreenT : Screen> {
3737
* that can update them to display [Screen] renderings of a particular [type], bundled
3838
* together in instances of [ScreenViewHolder].
3939
*
40-
* It is most common to create instances via [forViewBinding], [forLayoutResource],
41-
* [forStaticLayoutResource] or [forBuiltView].
40+
* Use [forLayoutResource], [forViewBinding], etc., to create a [ScreenViewFactory].
41+
* These helper methods take a layout resource, view binding, or view building
42+
* function as arguments, along with a factory to create a [showRendering]
43+
* [ScreenViewRunner.showRendering] function.
4244
*
4345
* It is rare to call [buildView] directly. Instead the most common path is to pass [Screen]
4446
* instances to [WorkflowViewStub.show], which will apply the [ScreenViewFactory] machinery
4547
* for you.
4648
*
4749
* If you are building a custom container and [WorkflowViewStub] is too restrictive,
48-
* use [Screen.startShowing], or [ScreenViewFactory.startShowing]. [startShowing]
49-
* is the fundamental method, responsible for making the initial call to [ScreenViewHolder.show],
50-
* and applying any [ViewStarter] provided for custom initialization.
50+
* use [ScreenViewFactory.startShowing].
5151
*/
5252
@WorkflowUiExperimentalApi
5353
public interface ScreenViewFactory<in ScreenT : Screen> : ViewRegistry.Entry<ScreenT> {
54+
/**
55+
* It is rare to call this method directly. Instead the most common path is to pass [Screen]
56+
* instances to [WorkflowViewStub.show], which will apply the [ScreenViewFactory] machinery
57+
* for you.
58+
*
59+
* Called by [startShowing] to create a [ScreenViewHolder] wrapping a [View] able to
60+
* display a stream of [ScreenT] renderings, starting with [initialRendering].
61+
*/
5462
public fun buildView(
5563
initialRendering: ScreenT,
5664
initialEnvironment: ViewEnvironment,
@@ -161,10 +169,13 @@ public interface ScreenViewFactory<in ScreenT : Screen> : ViewRegistry.Entry<Scr
161169
}
162170

163171
/**
172+
* It is rare to call this method directly. Instead the most common path is to pass [Screen]
173+
* instances to [WorkflowViewStub.show], which will apply the [ScreenViewFactory] machinery
174+
* for you.
175+
*
164176
* Use the [ScreenViewFactoryFinder] in [environment] to return the [ScreenViewFactory]
165177
* bound to the type of the receiving [Screen].
166178
*
167-
* - It is more common to use [WorkflowViewStub.show] than to call this method directly
168179
* - Call [ScreenViewFactory.startShowing] to create and initialize a new [View]
169180
* - If you don't particularly need to mess with the [ScreenViewFactory] before creating
170181
* a view, use [Screen.startShowing] instead of this method.
@@ -177,7 +188,9 @@ public fun <ScreenT : Screen> ScreenT.toViewFactory(
177188
}
178189

179190
/**
180-
* It is more common to use [WorkflowViewStub.show] than to call this method directly.
191+
* It is rare to call this method directly. Instead the most common path is to pass [Screen]
192+
* instances to [WorkflowViewStub.show], which will apply the [ScreenViewFactory] machinery
193+
* for you.
181194
*
182195
* Creates a [ScreenViewHolder] wrapping a [View] able to display a stream
183196
* of [ScreenT] renderings, starting with [initialRendering].

0 commit comments

Comments
 (0)