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

NavigatorProvider

public interface NavigatorProvider

androidx.navigation.NavigatorProvider


A NavigationProvider stores a set of Navigators that are valid ways to navigate to a destination.

Summary

Public methods

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

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

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

Register a navigator by name.

abstract <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.

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

Retrieves a registered Navigator by name.

Public methods

addNavigator

public abstract 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 abstract 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 abstract 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

Throws
IllegalArgumentException if the Navigator does not have a Navigator.Name annotation
IllegalStateException if the Navigator has not been added

getNavigator

public abstract 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

Throws
IllegalStateException if the Navigator has not been added