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 @Nullable Navigator<@NonNull NavDestination>

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

@CallSuper @Nullable Navigator<@NonNull NavDestination>
addNavigator(
    @NonNull String name,
    @NonNull Navigator<@NonNull NavDestination> navigator
)

Register a 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.

@CallSuper @NonNull T
<T extends Navigator<@NonNull ?>> getNavigator(@NonNull String name)

Retrieves a registered Navigator by name.

Extension functions

final @NonNull NavGraph
DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @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,
    @Nullable String route,
    @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

Construct a new DynamicGraphNavigator.DynamicNavGraph

final @NonNull NavGraph
NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @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,
    @Nullable String route,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

final @NonNull T

Retrieves a registered Navigator by name.

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 void

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

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

Register a Navigator by name.

Public fields

Public constructors

public final NavigatorProvider()

Public methods

addNavigator

@Nullable
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

@CallSuper
@Nullable
public @CallSuper 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
@CallSuper Navigator<@NonNull NavDestination>

the previously added Navigator for the given name, if any

getNavigator

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

getNavigator

@CallSuper
@NonNull
public @CallSuper 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
@CallSuper T

the registered navigator with the given name

Throws
kotlin.IllegalStateException

if the Navigator has not been added

See also
addNavigator

Extension functions

DynamicNavGraphBuilderKt.navigation

@NonNull
public final NavGraph DynamicNavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @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

@NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder

Another builder for chaining.

DynamicNavGraphBuilderKt.navigation

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

Construct a new DynamicGraphNavigator.DynamicNavGraph

Parameters
@NonNull String startDestination

route start destination in the graph

@Nullable String route

NavGraph route.

@NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder

Another builder for chaining.

NavGraphBuilderKt.navigation

@NonNull
public final NavGraph NavGraphBuilderKt.navigation(
    @NonNull NavigatorProvider receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @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

@NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
NavGraph

the newly constructed NavGraph

NavGraphBuilderKt.navigation

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

Construct a new NavGraph

Parameters
@