The Android Developer Challenge is back! Submit your idea before December 2.

NavigatorProvider

public class NavigatorProvider
extends Object

java.lang.Object
   ↳ androidx.navigation.NavigatorProvider


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

Summary

Public constructors

NavigatorProvider()

Public methods

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

final <T extends Navigator<?>> T getNavigator(Class<T> navigatorClass)

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

<T extends Navigator<?>> T getNavigator(String name)

Retrieves a registered Navigator by name.

Inherited methods

Public constructors

public NavigatorProvider ()

Public methods

addNavigator

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