NavigatorProvider
public class NavigatorProvider
A NavigationProvider stores a set of Navigators that are valid ways to navigate to a destination.
Summary
Public constructors |
|---|
Public methods |
|
|---|---|
final Navigator<@NonNull NavDestination> |
addNavigator(@NonNull Navigator<@NonNull NavDestination> navigator)Register a navigator using the name provided by the |
Navigator<@NonNull NavDestination> |
@CallSuperRegister a navigator by name. |
@NonNull T |
Retrieves a registered |
final @NonNull T |
@CallSuperRetrieves a registered |
Public constructors
Public methods
addNavigator
public final Navigator<@NonNull NavDestination> addNavigator(@NonNull Navigator<@NonNull 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 | |
|---|---|
@NonNull Navigator<@NonNull NavDestination> navigator |
navigator to add |
| Returns | |
|---|---|
Navigator<@NonNull NavDestination> |
the previously added Navigator for the name provided by the |
addNavigator
@CallSuper
public Navigator<@NonNull NavDestination> addNavigator(
@NonNull String name,
@NonNull Navigator<@NonNull 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 | |
|---|---|
@NonNull String name |
name for this navigator |
@NonNull Navigator<@NonNull NavDestination> navigator |
navigator to add |
| Returns | |
|---|---|
Navigator<@NonNull NavDestination> |
the previously added Navigator for the given name, if any |
getNavigator
@CallSuper
public @NonNull T <T extends Navigator<@NonNull ?>> getNavigator(@NonNull String name)
Retrieves a registered Navigator by name.
| Returns | |
|---|---|
@NonNull T |
the registered navigator with the given name |
| Throws | |
|---|---|
kotlin.IllegalStateException |
if the Navigator has not been added |
| See also | |
|---|---|
addNavigator |
getNavigator
@CallSuper
public final @NonNull T <T extends Navigator<@NonNull ?>> getNavigator(
@NonNull Class<@NonNull T> navigatorClass
)
Retrieves a registered Navigator using the name provided by the Navigator.Name annotation.
| Returns | |
|---|---|
@NonNull T |
the registered navigator with the given |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the Navigator does not have a |
kotlin.IllegalStateException |
if the Navigator has not been added |
| See also | |
|---|---|
addNavigator |
Extension functions
DynamicNavGraphBuilderKt.navigation
public final @NonNull NavGraph DynamicNavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@IdRes int id,
@IdRes int startDestination,
@NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
Construct a new DynamicGraphNavigator.DynamicNavGraph
DynamicNavGraphBuilderKt.navigation
public final @NonNull NavGraph DynamicNavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@NonNull String startDestination,
String route,
@NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
Construct a new DynamicGraphNavigator.DynamicNavGraph
DynamicNavGraphBuilderKt.navigation
public final @NonNull NavGraph DynamicNavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@NonNull Object startDestination,
KClass<@NonNull ?> route,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
@NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
Construct a new DynamicGraphNavigator.DynamicNavGraph
| Parameters | |
|---|---|
@NonNull Object startDestination |
the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added with route from a |
KClass<@NonNull ?> route |
the graph's unique route as a |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
A mapping of KType to custom NavType<*> in the |
@NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder |
Another builder for chaining. |
DynamicNavGraphBuilderKt.navigation
public final @NonNull NavGraph DynamicNavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@NonNull KClass<@NonNull ?> startDestination,
KClass<@NonNull ?> route,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
@NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
Construct a new DynamicGraphNavigator.DynamicNavGraph
| Parameters | |
|---|---|
@NonNull KClass<@NonNull ?> startDestination |
the starting destination's route from a |
KClass<@NonNull ?> route |
the graph's unique route as a |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
A mapping of KType to custom NavType<*> in the |
@NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder |
Another builder for chaining. |
NavGraphBuilderKt.navigation
public final @NonNull NavGraph NavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@IdRes int id,
@IdRes int startDestination,
@NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
Construct a new NavGraph
NavGraphBuilderKt.navigation
public final @NonNull NavGraph NavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@NonNull String startDestination,
String route,
@NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
Construct a new NavGraph
NavGraphBuilderKt.navigation
public final @NonNull NavGraph NavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@NonNull Object startDestination,
KClass<@NonNull ?> route,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
@NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
Construct a new NavGraph
| Parameters | |
|---|---|
@NonNull Object startDestination |
the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added with route from a |
KClass<@NonNull ?> route |
the graph's unique route as a |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
A mapping of KType to custom NavType<*> in the |
@NonNull Function1<@NonNull NavGraphBuilder, Unit> builder |
the builder used to construct the graph |
NavGraphBuilderKt.navigation
public final @NonNull NavGraph NavGraphBuilderKt.navigation(
@NonNull NavigatorProvider receiver,
@NonNull KClass<@NonNull ?> startDestination,
KClass<@NonNull ?> route,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
@NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
Construct a new NavGraph
| Parameters | |
|---|---|
@NonNull KClass<@NonNull ?> startDestination |
the starting destination's route from a |
KClass<@NonNull ?> route |
the graph's unique route as a |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
A mapping of KType to custom NavType<*> in the |
@NonNull Function1<@NonNull NavGraphBuilder, Unit> builder |
the builder used to construct the graph |
NavigatorProviderKt.get
public final @NonNull T <T extends Navigator<@NonNull NavDestination>> NavigatorProviderKt.get(
@NonNull NavigatorProvider receiver,
@NonNull KClass<@NonNull T> clazz
)
Retrieves a registered Navigator using the name provided by the Navigator.Name annotation.
| Throws | |
|---|---|
kotlin.IllegalStateException |
if the Navigator has not been added |
NavigatorProviderKt.get
public final @NonNull T <T extends Navigator<@NonNull NavDestination>> NavigatorProviderKt.get(
@NonNull NavigatorProvider receiver,
@NonNull String name
)
Retrieves a registered Navigator by name.
| Throws | |
|---|---|
kotlin.IllegalStateException |
if the Navigator has not been added |
NavigatorProviderKt.plusAssign
public final void NavigatorProviderKt.plusAssign(
@NonNull NavigatorProvider receiver,
@NonNull Navigator<@NonNull NavDestination> navigator
)
Register a navigator using the name provided by the Navigator.Name annotation.
NavigatorProviderKt.set
public final Navigator<@NonNull NavDestination> NavigatorProviderKt.set(
@NonNull NavigatorProvider receiver,
@NonNull String name,
@NonNull Navigator<@NonNull NavDestination> navigator
)
Register a Navigator by name. If a navigator by this name is already registered, this new navigator will replace it.
| Returns | |
|---|---|
Navigator<@NonNull NavDestination> |
the previously added |