CompositeReplacingNavigator

In package com.nhaarman.acorn.navigation

class com.nhaarman.acorn.navigation.CompositeReplacingNavigator

A navigator class that can switch between Scenes, but has no 'back' behavior of its own.

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?)

A navigator class that can switch between Scenes, but has no 'back' behavior of its own.

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 initialNavigator(): Navigator

Creates the initial Navigator for this CompositeReplacingNavigator.

Will only be called once in the lifetime of this Navigator, and zero times if this Navigator is being restored from a saved state.

Parameters:
  • No parameters
protected abstract fun instantiateNavigator(navigatorClass: KClass, state: NavigatorState?): Navigator

Instantiates a Navigator instance for given navigatorClass and state.

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

Parameters:
  • navigatorClass: KClass

    The Class of the Navigator to instantiate.

  • state: NavigatorState?

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

open fun addNavigatorEventsListener(listener: Events): DisposableHandle

Registers given listener with this Navigator.

Parameters:
fun replace(navigator: Navigator)

Replaces the current Navigator with given navigator.

If the receiving Navigator is currently active, the current child Navigator will be stopped and destroyed, and given navigator will receive a call to Navigator.onStart.

If the receiving Navigator is currently inactive, the current child Navigator will be destroyed. Starting the receiving Navigator will trigger a call to the Navigator.onStart method of given navigator.

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

Parameters:
fun finish()

Finishes this Navigator.

If this Navigator is currently active, the current child Navigator will be stopped and destroyed, and the receiving Navigator will be destroyed.

If this Navigator is currently not active, the current navigator 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 scene(scene: Scene, data: TransitionData?)

Called when a Scene change occurs in the Navigator.

Will only be called if a Scene change occurs when the Navigator is in the started state, or when the Navigator enters the started state.

Parameters:
open fun finished()

Called when the Navigator has finished.

Finish events occur when the Navigator has no more Scenes to show, such as a stack-based Navigator with an empty stack, or a wizard Navigator that reached the end of the wizard.

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