WizardNavigator

In package com.nhaarman.acorn.navigation

class com.nhaarman.acorn.navigation.WizardNavigator

An abstract Navigator class that is able to go back and forth through a list of Scenes.

This Navigator has two methods next and previous to navigate through the Scenes. Calling previous when the first Scene is being shown will have no effect, calling next when the last Scene is being shown will finish this Navigator.

Implementers must implement createScene to provide the proper Scenes.

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

Constructors

constructor(savedState: NavigatorState?)

An abstract Navigator class that is able to go back and forth through a list of Scenes.

This Navigator has two methods next and previous to navigate through the Scenes. Calling previous when the first Scene is being shown will have no effect, calling next when the last Scene is being shown will finish this Navigator.

Implementers must implement createScene to provide the proper Scenes.

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

Parameters:
  • savedState: NavigatorState?

    An optional instance that contains saved state as returned by saveInstanceState.

Methods

protected abstract fun createScene(index: Int): Scene?

Creates the Scene for given index, starting at 0.

This method will be called up to once for each index, results will be reused when navigating through the wizard.

Parameters:
  • index: Int
protected abstract fun instantiateScene(sceneClass: KClass, state: SceneState?): Scene

Instantiates a Scene instance for given sceneClass and state.

This function is called when restoring the StackNavigator from a saved state.

Parameters:
  • sceneClass: KClass

    The class of the Scene to instantiate.

  • state: SceneState?

    The saved state of the Scene if applicable. This will be the instance as returned from SavableScene.saveInstanceState if its state was saved.

open fun addNavigatorEventsListener(listener: Events): DisposableHandle

Registers given listener with this Navigator.

Parameters:
fun next()

Navigates to the next Scene in this wizard if possible.

If there is no next Scene, this Navigator will finish and all Scenes will be destroyed.

If there is a next Scene and this Navigator is currently active, the current Scene will be stopped, and the next Scene will be started.

If there is a next Scene and this Navigator is currently inactive, no Scene lifecycle events will be called at all. Starting this Navigator will trigger a call to the Scene.onStart of the next Scene in the wizard.

Calling this method when this Navigator has been destroyed will have no effect.

Parameters:
  • No parameters
fun previous()

Navigates to the next Scene in this wizard if possible.

If there is no previous Scene, nothing will happen.

If there is a previous Scene and this Navigator is currently active, the current Scene will be stopped, and the previous Scene will be started.

If there is a previous Scene and this Navigator is currently inactive, no Scene lifecycle events will be called at all. Starting this Navigator will trigger a call to the Scene.onStart of the previous Scene in the wizard.

Calling this method when this Navigator has been destroyed will have no effect.

Parameters:
  • No parameters
fun finish()

Finishes this Navigator.

If this Navigator is currently active, the current Scene will go through its destroying lifecycle calling Scene.onStop and Scene.onDestroy.

If this Navigator is currently not active, the current Scene will only have its Scene.onDestroy method called.

Calling this method when the Navigator has been destroyed will have no effect.

Parameters:
  • No parameters
open fun onStart()

Starts this Navigator.

Calling this method when the Navigator is not started or destroyed triggers a call to Scene.onStart for the Scene that is currently active in the Navigator. Listeners registered with addNavigatorEventsListener will be notified of that Scene through Events.scene.

Calling this method when the Navigator is started or destroyed has no effect.

Parameters:
  • No parameters
open fun onStop()

Stops this Navigator.

Calling this method when the Navigator is started triggers a call to Scene.onStop for any Scenes that are currently active in the Navigator.

Calling this method when the Navigator is stopped or destroyed has no effect.

Parameters:
  • No parameters
open fun onDestroy()

Destroys this Navigator.

Calling this method when the Navigator is started will trigger a call to Scene.onStop for the Scene that is currently active in the Navigator. Furthermore, a call to Scene.onDestroy is triggered for every Scene this Navigator is managing.

Calling this method when the Navigator is stopped triggers a call to Scene.onDestroy for every Scene this Navigator is managing.

Calling this method when the Navigator is destroyed has no effect.

When this method has been called, the Navigator must be considered as dead, and no calls to onStart or onStop should be done anymore.

Parameters:
  • No parameters
open fun onBackPressed(): Boolean

Invoked when the user presses the back button.

Parameters:
  • No parameters
open fun saveInstanceState(): NavigatorState
Parameters:
  • No parameters
open fun isDestroyed(): Boolean

Returns whether this Navigator has been destroyed.

Parameters:
  • No parameters