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>

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

Navigator<@NonNull NavDestination>

Register a navigator by name.

@NonNull T

Retrieves a registered Navigator by name.

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.

Extension functions

final @NonNull NavGraph
DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

This method is deprecated. Use routes to create your DynamicNavGraph instead

final @NonNull NavGraph
DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull String startDestination,
    String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

final @NonNull NavGraph
DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

final @NonNull NavGraph
DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

final @NonNull NavGraph
NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

This method is deprecated. Use routes to build your NavGraph instead

final @NonNull NavGraph
NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull String startDestination,
    String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

final @NonNull NavGraph
NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

final @NonNull NavGraph
NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

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.

final @NonNull T

Retrieves a registered Navigator by name.

final void

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

final Navigator<@NonNull NavDestination>
NavigatorProviderKt.set(
    @NonNull NavigatorProvider receiver,
    @NonNull String name,
    @NonNull Navigator<@NonNull NavDestination> navigator
)

Register a Navigator by name.

Public constructors

Added in 1.0.0
public NavigatorProvider()

Public methods

addNavigator

Added in 1.0.0
public final Navigator<@NonNull NavDestinationaddNavigator(@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 Navigator.Name annotation, if any

addNavigator

Added in 1.0.0
@CallSuper
public Navigator<@NonNull NavDestinationaddNavigator(
    @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

Added in 1.0.0
@CallSuper
public @NonNull T <T extends Navigator<@NonNull ?>> getNavigator(@NonNull String name)

Retrieves a registered Navigator by name.

Parameters
@NonNull String name

name of the navigator to return

Returns
@NonNull T

the registered navigator with the given name

Throws
kotlin.IllegalStateException

if the Navigator has not been added

See also
addNavigator

getNavigator

Added in 1.0.0
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.

Parameters
@NonNull Class<@NonNull T> navigatorClass

class of the navigator to return

Returns
@NonNull T

the registered navigator with the given Navigator.Name

Throws
kotlin.IllegalArgumentException

if the Navigator does not have a Navigator.Name annotation

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,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

Parameters
@IdRes int id

NavGraph id.

@IdRes int startDestination

Id start destination in the graph

@ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder

Another builder for chaining.

DynamicNavGraphBuilderKt.navigation

public final @NonNull NavGraph DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull String startDestination,
    String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

Parameters
@NonNull String startDestination

route start destination in the graph

String route

NavGraph route.

@ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder

Another builder for chaining.

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,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> 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 in order to match.

KClass<@NonNull ?> route

the graph's unique route as a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> 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,
    @ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

Parameters
@NonNull KClass<@NonNull ?> startDestination

the starting destination's route from a KClass for this NavGraph. The respective NavDestination must be added with route from a KClass in order to match.

KClass<@NonNull ?> route

the graph's unique route as a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder

Another builder for chaining.

NavGraphBuilderKt.navigation

public final @NonNull NavGraph NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

Parameters
@IdRes int id

the destination's unique id

@IdRes int startDestination

the starting destination for this NavGraph

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
@NonNull NavGraph

the newly constructed NavGraph

NavGraphBuilderKt.navigation

public final @NonNull NavGraph NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @NonNull String startDestination,
    String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

Parameters
@NonNull String startDestination

the starting destination's route for this NavGraph

String route

the destination's unique route

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
@NonNull NavGraph

the newly constructed 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,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> 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 in order to match.

KClass<@NonNull ?> route

the graph's unique route as a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
@NonNull NavGraph

the newly constructed NavGraph

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,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

Parameters
@NonNull KClass<@NonNull ?> startDestination

the starting destination's route from a KClass for this NavGraph. The respective NavDestination must be added with route from a KClass in order to match.

KClass<@NonNull ?> route

the graph's unique route as a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
@NonNull NavGraph

the newly constructed NavGraph

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 NavDestinationNavigatorProviderKt.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 Navigator for the given name, if any