Scene

In package com.nhaarman.acorn.presentation

class com.nhaarman.acorn.presentation.Scene

A Scene is a destination in the application the user can navigate to.

Scenes are the boundary between your application logic and the UI that is displayed to the user.

The lifecycle of a Scene is very simple:

  • 'stopped' : The Scene is dormant, waiting to be started or to be destroyed.
  • 'started' : The Scene is started.
  • 'destroyed': The Scene is destroyed and will not be started anymore.

On top of that, the user interface can attach to and detach itself from this Scene via the attach and detach methods, providing interaction with the user. It is therefore possible that the Scene is started without having a user interface attached.

Scenes may implement SavableScene to indicate that their instance state can be saved. When this is the case, SavableScene.saveInstanceState will be called at the appropriate time.

Fields

open key: SceneKey

A unique identifier for this Scene.

This key can be used to determine what layout to show, and can be used to save and restore instance state, if needed.

Methods

open fun onStart()

Called when this Scene is started.

Parameters:
  • No parameters
open fun attach(v: V)

Attaches given V to this Scene.

Parameters:
  • v: V

    The user interface that is being attached.

open fun detach(v: V)

Detaches any views from this scene.

Will always be preceded by a call to attach.

Parameters:
  • v: V
open fun onStop()

Called when this Scene is stopped.

Parameters:
  • No parameters
open fun onDestroy()

Called when this Scene will be destroyed.

After a call to this method no more calls should be made to this Scene.

Parameters:
  • No parameters