In package com.nhaarman.acorn.navigation
class com.nhaarman.acorn.navigation.Navigator
An interface that describes a flow through the application.
The Navigator is a class that takes care of navigating the user through an application by showing a sequence of Scenes. Interested parties may subscribe a listener using addNavigatorEventsListener, through which Scene changes will be published.
Navigators are responsible for handling the lifecycles of the Scenes they manage. To be able to do this, the Navigator has a very simple lifecycle as well:
stopped
: The Navigator is currently idle and will not emit any changes in Scenery.started
: The Navigator is currently started and will notify interested parties of changes in Scenes.destroyed
: The Navigator has been destroyed and will not be started anymore.
Navigator instances start in the stopped
state and can switch between
stopped
and started
an infinite amount of times.
Once a Navigator has been destroyed, it must be considered as dead, and any
further interactions with it will be ignored.
Navigators that are not started
must never have Scenes in their started
state.
Navigators may implement SavableNavigator to indicate that their instance state can be saved. When this is the case, SavableNavigator.saveInstanceState will be called at the appropriate time.
Methods
abstract 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.
- No parameters
abstract 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.
- No parameters
abstract 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.
- No parameters
abstract fun isDestroyed(): Boolean
Returns whether this Navigator has been destroyed.
- No parameters