Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

TestNavigatorProvider

public class TestNavigatorProvider
extends Object implements NavigatorProvider

java.lang.Object
   ↳ androidx.navigation.testing.TestNavigatorProvider


Simple NavigatorProvider that only supports <navigation> and <test> navigation elements.

Summary

Public constructors

TestNavigatorProvider(Context context)

Public methods

Navigator<? extends NavDestination> addNavigator(Navigator<? extends NavDestination> navigator)

Register a navigator using the name provided by the Navigator.Name annotation.

Navigator<? extends NavDestination> addNavigator(String name, Navigator<? extends NavDestination> navigator)

Register a navigator by name.

<D extends NavDestination, T extends Navigator<? extends D>> T getNavigator(Class<T> navigatorClass)

Retrieves a registered Navigator using the name provided by the Navigator.Name annotation.

<D extends NavDestination, T extends Navigator<? extends D>> T getNavigator(String name)

Retrieves a registered Navigator by name.

Inherited methods

Public constructors

TestNavigatorProvider

public TestNavigatorProvider (Context context)

Parameters
context Context

Public methods

addNavigator

public Navigator<? extends NavDestination> addNavigator (Navigator<? extends NavDestination> navigator)

Register a navigator using the name provided by the Navigator.Name annotation. destinations may refer to any registered navigator by name for inflation. If a navigator by this name is already registered, this new navigator will replace it.

Parameters
navigator Navigator: navigator to add

Returns
Navigator<? extends NavDestination> the previously added Navigator for the name provided by the Navigator.Name annotation, if any

addNavigator

public Navigator<? extends NavDestination> addNavigator (String name, 
                Navigator<? extends NavDestination> navigator)

Register a navigator by name. destinations may refer to any registered navigator by name for inflation. If a navigator by this name is already registered, this new navigator will replace it.

Parameters
name String: name for this navigator

navigator Navigator: navigator to add

Returns
Navigator<? extends NavDestination> the previously added Navigator for the given name, if any

getNavigator

public T getNavigator (Class<T> navigatorClass)

Retrieves a registered Navigator using the name provided by the Navigator.Name annotation.

Parameters
navigatorClass Class: class of the navigator to return

Returns
T the registered navigator with the given Navigator.Name

getNavigator

public T getNavigator (String name)

Retrieves a registered Navigator by name.

Parameters
name String: name of the navigator to return

Returns
T the registered navigator with the given name