View Compose Worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.squareup.sample.compose.hellocomposebinding | |
import com.squareup.sample.compose.hellocomposebinding.HelloWorkflow.Rendering | |
import com.squareup.sample.compose.hellocomposebinding.HelloWorkflow.HG | |
import com.squareup.sample.compose.hellocomposebinding.HelloWorkflow.HG.Goodbye | |
import com.squareup.sample.compose.hellocomposebinding.HelloWorkflow.HG.Hello | |
import com.squareup.sample.compose.hellocomposebinding.HelloWorkflow.State | |
import com.squareup.sample.compose.hellocomposeworkflow.HelloWorkflow | |
import com.squareup.workflow1.Snapshot | |
import com.squareup.workflow1.StatefulWorkflow |
View TextController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.squareup.workflow.pos.text | |
import android.text.Editable | |
import android.text.TextWatcher | |
import android.widget.EditText | |
import android.widget.TextView | |
import com.squareup.util.coroutines.launchWhenAttached | |
import com.squareup.workflow1.ExperimentalWorkflowApi | |
import kotlinx.coroutines.Job | |
import kotlinx.coroutines.flow.Flow |
View ActivityAsWorkflowProps.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(WorkflowUiExperimentalApi::class) | |
class HelloWorkflowActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// This ViewModel will survive configuration changes. It's instantiated | |
// by the first call to viewModels(), and that original instance is returned by | |
// succeeding calls. | |
val model: HelloViewModel by viewModels() |
View Gatekeeper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In our production code, this typealias is more interesting, | |
* something like AlertContainerScreen<PanelContainerScreen<R>> | |
*/ | |
typealias MetaRootRendering<R>: AlertContainerScreen<R> | |
data class ActivityAndRoot<R> ( | |
val activity: Activity, | |
val root: R | |
) |
View java-sealed-class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* For Java developers all excited by and jealous of Kotlin's sealed classes. | |
* Do this when you wish you could put parameters on an enum. | |
*/ | |
public class PoorMan { | |
interface Event { | |
<T> T dispatch(EventHandler<T> handler); | |
} | |
interface EventHandler<T> { |
View NewViewPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mortar; | |
import android.view.View; | |
import mortar.bundler.BundleService; | |
public class NewViewPresenter<V extends View> extends NewPresenter<V> { | |
@Override protected final MortarScope extractScope(V view) { | |
return MortarScope.getScope(view.getContext()); | |
} | |
} |
View NewPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mortar; | |
public abstract class NewPresenter<V> { | |
private V view = null; | |
private Scoped registration = new Scoped() { | |
@Override public void onEnterScope(MortarScope scope) { | |
NewPresenter.this.onEnterScope(scope); | |
} |