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

NavigatorProvider

open class NavigatorProvider
kotlin.Any
   ↳ androidx.navigation.NavigatorProvider

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

Summary

Public constructors

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

Public methods

Navigator<out NavDestination!>?
addNavigator(@NonNull navigator: Navigator<out NavDestination!>)

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

open Navigator<out NavDestination!>?
addNavigator(@NonNull name: String, @NonNull navigator: Navigator<out NavDestination!>)

Register a navigator by name.

T
getNavigator(@NonNull navigatorClass: Class<T>)

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

open T
getNavigator(@NonNull name: String)

Retrieves a registered Navigator by name.

Extension functions

From androidx.navigation
operator T

Retrieves a registered Navigator by name.

operator T

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

NavGraph
NavigatorProvider.navigation(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

Construct a new NavGraph

operator Unit

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

operator Navigator<out NavDestination!>?

Register a Navigator by name.

Public constructors

<init>

NavigatorProvider()

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

Public methods

addNavigator

@Nullable fun addNavigator(@NonNull navigator: Navigator<out NavDestination!>): Navigator<out NavDestination!>?

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<out NavDestination!>: navigator to add
Return
Navigator<out NavDestination!>?: the previously added Navigator for the name provided by the Navigator.Name annotation, if any

addNavigator

@CallSuper @Nullable open fun addNavigator(@NonNull name: String, @NonNull navigator: Navigator<out NavDestination!>): Navigator<out NavDestination!>?

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 String: navigator to add
Return
Navigator<out NavDestination!>?: the previously added Navigator for the given name, if any

getNavigator

@NonNull fun <T : Navigator<*>!> getNavigator(@NonNull navigatorClass: Class<T>): T

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

Parameters
navigatorClass Class<T>: class of the navigator to return
Return
T: the registered navigator with the given Navigator.Name
Exceptions
IllegalArgumentException if the Navigator does not have a Navigator.Name annotation
IllegalStateException if the Navigator has not been added

getNavigator

@CallSuper @NonNull open fun <T : Navigator<*>!> getNavigator(@NonNull name: String): T

Retrieves a registered Navigator by name.

Parameters
name String: name of the navigator to return
Return
T: the registered navigator with the given name
Exceptions
IllegalStateException if the Navigator has not been added