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.

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