Skip to content

Instantly share code, notes, and snippets.

@stoichoandreev
Last active March 18, 2020 09:42
Show Gist options
  • Save stoichoandreev/52527647ef43fb9fdd4e96eee03494c4 to your computer and use it in GitHub Desktop.
Save stoichoandreev/52527647ef43fb9fdd4e96eee03494c4 to your computer and use it in GitHub Desktop.
Gist 1 B None Android Example
class AndroidLifeCycleComponent {
fun start() {
System.out.println("Robot Start")
}
fun resume() {
System.out.println("Robot Resume")
}
fun stop() {
System.out.println("Robot stop")
}
fun terminate() {
System.out.println("Robot terminate")
}
}
class AndroidRobot(private val lifeCycleComponent: AndroidLifeCycleComponent) {
fun onCreate() {
lifeCycleComponent.start()
}
fun onResume() {
lifeCycleComponent.resume()
}
fun onPause() {
lifeCycleComponent.stop()
}
fun onShutdown() {
lifeCycleComponent.terminate()
}
}
class FucsiaLifeCycleComponent {
fun start() {
System.out.println("Robot Start")
}
fun paint() {
System.out.println("Robot Paint")
}
fun stop() {
System.out.println("Robot stop")
}
fun terminate() {
System.out.println("Robot terminate")
}
}
class FucsiaRobot(private val lifeCycleComponent: FucsiaLifeCycleComponent) {
fun onCanvasInitialised() {
lifeCycleComponent.start()
}
fun onCanvasDrawn() {
lifeCycleComponent.paint()
}
fun onCanvasClosed() {
lifeCycleComponent.stop()
}
fun onCanvasTerminated() {
lifeCycleComponent.terminate()
}
}
class IOSLifeCycleComponent {
fun start() {
System.out.println("Robot Start")
}
fun stop() {
System.out.println("Robot stop")
}
fun terminate() {
System.out.println("Robot terminate")
}
}
class IOSRobot(private val lifeCycleComponent: IOSLifeCycleComponent) {
fun onViewDidLoad() {
lifeCycleComponent.start()
}
fun onViewDisappear() {
lifeCycleComponent.stop()
}
fun onViewReleaseFromMemory() {
lifeCycleComponent.terminate()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment