In package com.nhaarman.acorn.navigation.experimental
class com.nhaarman.acorn.navigation.experimental.ConcurrentPairNavigator
An abstract Navigator class that supports a second, overlapping Scene.
This Navigator supports two states: one where only the initial Scene is active, and one where both the initial Scene and an additional Scene are active. When adding the second Scene using push, both the initial and the additional Scene will be in their 'started' state. This can be useful when showing a sophisticated modal kind of overlay.
When the additional Scene is pushed, this Navigator wraps both the initial Scene and the second Scene in a CombinedScene and notifies interested Navigator.Events of this CombinedScene.
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
An abstract Navigator class that supports a second, overlapping Scene.
This Navigator supports two states: one where only the initial Scene is active, and one where both the initial Scene and an additional Scene are active. When adding the second Scene using push, both the initial and the additional Scene will be in their 'started' state. This can be useful when showing a sophisticated modal kind of overlay.
When the additional Scene is pushed, this Navigator wraps both the initial Scene and the second Scene in a CombinedScene and notifies interested Navigator.Events of this CombinedScene.
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.
-
savedState: NavigatorState?
An optional instance that contains saved state as returned by saveInstanceState.
Methods
protected abstract fun createInitialScene(): Scene
Creates the initial Scene for this ConcurrentPairNavigator.
- No parameters
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 ConcurrentPairNavigator from a saved state.
-
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.
fun push(scene: Scene)
Sets given Scene as the second Scene in this ConcurrentPairNavigator.
If this Navigator is currently active and there is already a second Scene active, this second Scene will be stopped and destroyed. Given Scene will receive a call to Scene.onStart. The initial Scene will receive no lifecycle methods.
If this Navigator is currently inactive and there is already a second Scene active, this second Scene will be destroyed. No further lifecycle methods will be called. Starting this Navigator will start both the initial Scene and given second Scene.
Calling this method when this Navigator has been destroyed will have no effect.
-
scene: Scene
The Scene instance to push.
fun pop()
Removes the second Scene if there is any.
If there is no second Scene, nothing will happen.
If this Navigator is currently active and there is a second Scene, this second Scene will be stopped and destroyed.
If this Navigator is currently inactive and there is a second Scene, this second Scene will be destroyed.
Calling this method when the receiving Navigator has been destroyed will have no effect.
- No parameters
fun finish()
Finishes this Navigator.
If this Navigator is currently active, any active Scenes will go through their destroying lifecycles calling Scene.onStop and Scene.onDestroy.
If this Navigator is currently not active, any active Scenes will only have their Scene.onDestroy method called.
Calling this method when the Navigator has been destroyed will have no effect.
- 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.
- 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.
- 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.
- No parameters
open fun onBackPressed(): Boolean
Invoked when the user presses the back button.
- No parameters
open fun isDestroyed(): Boolean
Returns whether this Navigator has been destroyed.
- No parameters
- No parameters