BasicScene

In package com.nhaarman.acorn.presentation

class com.nhaarman.acorn.presentation.BasicScene

An abstract basic Scene implementation that provides commonly used functionality.

This class provides an attachedView property which provides the currently attached V instance, if available.

If the Container type V implements RestorableContainer, this class will save and restore the view state between subsequent calls to attach and detach.

This class is able to save and restore its instance state in saveInstanceState, but does not implement SavableScene itself. You can opt in to this state saving by explicitly implementing the SavableScene interface.

Fields

protected var attachedView: V?

The currently attached V instance, if available.

This property will be updated when attach or detach is called.

Returns null if no instance is attached.

Constructors

constructor(savedState: SceneState?)

Creates a new BasicScene, restoring view state when available.

Parameters:

Methods

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 saveInstanceState(): SceneState

Saves the instance state for this Scene.

The default implementation of this method will save the view state if V implements RestorableContainer.

Implementers of this class may override this method to save additional information. However, it is recommended to call the default implementation.

Parameters:
  • No parameters