TestNavigator

public class TestNavigator
extends Navigator<TestNavigator.Destination>

java.lang.Object
   ↳ androidx.navigation.Navigator<androidx.navigation.testing.TestNavigator.Destination>
     ↳ androidx.navigation.testing.TestNavigator


A simple Navigator that doesn't actually navigate anywhere, but does dispatch correctly

Summary

Nested classes

class TestNavigator.Destination

A simple Test destination  

Inherited constants

Fields

public final ArrayDeque<Pair<TestNavigator.DestinationBundle>> mBackStack

Public constructors

TestNavigator()

Public methods

TestNavigator.Destination createDestination()

Construct a new NavDestination associated with this Navigator.

void navigate(TestNavigator.Destination destination, Bundle args, NavOptions navOptions)

Navigate to a destination.

boolean popBackStack()

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Inherited methods

Fields

mBackStack

ArrayDeque<Pair<TestNavigator.DestinationBundle>> mBackStack

Public constructors

TestNavigator

TestNavigator ()

Public methods

createDestination

TestNavigator.Destination createDestination ()

Construct a new NavDestination associated with this Navigator.

Any initialization of the destination should be done in the destination's constructor as it is not guaranteed that every destination will be created through this method.

Returns
TestNavigator.Destination a new NavDestination

navigate

void navigate (TestNavigator.Destination destination, 
                Bundle args, 
                NavOptions navOptions)

Navigate to a destination.

Requests navigation to a given destination associated with this navigator in the navigation graph. This method generally should not be called directly; NavController will delegate to it when appropriate.

Implementations should dispatchOnNavigatorNavigated(int, int) to notify listeners of the resulting navigation destination.

Parameters
destination TestNavigator.Destination: destination node to navigate to

args Bundle: arguments to use for navigation

navOptions NavOptions: additional options for navigation

popBackStack

boolean popBackStack ()

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Implementations should dispatchOnNavigatorNavigated(int, int) to notify listeners of the resulting navigation destination and return true if navigation was successful. Implementations should return false if navigation could not be performed, for example if the navigator's back stack was empty.

Returns
boolean true if pop was successful