NavDestinationBuilder
@NavDestinationDsl
public class NavDestinationBuilder<D extends NavDestination>
ActivityNavigatorDestinationBuilder |
DSL for constructing a new |
DialogFragmentNavigatorDestinationBuilder |
DSL for constructing a new |
DynamicActivityNavigatorDestinationBuilder |
DSL for constructing a new |
DynamicFragmentNavigatorDestinationBuilder |
DSL for constructing a new |
DynamicIncludeNavGraphBuilder |
DSL for constructing a new |
FragmentNavigatorDestinationBuilder |
DSL for constructing a new |
NavGraphBuilder |
DSL for constructing a new |
DynamicNavGraphBuilder |
DSL for constructing a new |
DSL for constructing a new NavDestination
Summary
Public constructors |
|---|
<D extends NavDestination> This method is deprecated. Use routes to build your NavDestination instead |
<D extends NavDestination> NavDestinationBuilder(DSL for constructing a new |
<D extends NavDestination> NavDestinationBuilder(DSL for constructing a new |
Public methods |
|
|---|---|
final void |
This method is deprecated. Building NavDestinations using IDs with the Kotlin DSL has been deprecated in favor of using routes. |
final void |
argument(Add a |
final void |
argument(@NonNull String name, @NonNull NavArgument argument)Add a |
@NonNull D |
build()Build the NavDestination by calling |
final void |
deepLink(Add a deep link to this destination. |
final void |
deepLink(@NonNull NavDeepLink navDeepLink)Add a deep link to this destination. |
final void |
<T extends Object> deepLink(Add a deep link to this destination. |
final void |
<T extends Object> deepLink(Add a deep link to this destination. |
final void |
<T extends Object> deepLinkSafeArgs(@NonNull String basePath)Add a deep link to this destination. |
final void |
<T extends Object> deepLinkSafeArgs(@NonNull String uriPattern)Add a deep link to this destination. |
final int |
getId()The destination's unique ID. |
final CharSequence |
getLabel()The descriptive label of the destination |
final String |
getRoute()The destination's unique route. |
final void |
setLabel(CharSequence label)The descriptive label of the destination |
Protected methods |
|
|---|---|
final @NonNull Navigator<@NonNull D> |
The navigator the destination that will be used in |
@NonNull D |
Instantiate a new instance of |
Public constructors
NavDestinationBuilder
public <D extends NavDestination>NavDestinationBuilder(
@NonNull Navigator<@NonNull D> navigator,
@IdRes int id
)
DSL for constructing a new NavDestination with a unique id.
This sets the destination's route to null.
| Parameters | |
|---|---|
@NonNull Navigator<@NonNull D> navigator |
navigator used to create the destination |
@IdRes int id |
the destination's unique id |
| Returns | |
|---|---|
NavDestinationBuilder<@NonNull D> |
the newly constructed |
NavDestinationBuilder
public <D extends NavDestination> NavDestinationBuilder(
@NonNull Navigator<@NonNull D> navigator,
String route
)
DSL for constructing a new NavDestination with a unique route.
This will also update the id of the destination based on route.
| Parameters | |
|---|---|
@NonNull Navigator<@NonNull D> navigator |
navigator used to create the destination |
String route |
the destination's unique route |
| Returns | |
|---|---|
NavDestinationBuilder<@NonNull D> |
the newly constructed |
NavDestinationBuilder
public <D extends NavDestination> NavDestinationBuilder(
@NonNull Navigator<@NonNull D> navigator,
KClass<@NonNull ?> route,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)
DSL for constructing a new NavDestination with a serializable KClass.
This will also update the id of the destination based on KClass's serializer.
| Parameters | |
|---|---|
@NonNull Navigator<@NonNull D> navigator |
navigator used to create the destination |
KClass<@NonNull ?> route |
the |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
map of destination arguments' kotlin type |
| Returns | |
|---|---|
NavDestinationBuilder<@NonNull D> |
the newly constructed |
Public methods
public final voidaction(
int actionId,
@NonNull Function1<@NonNull NavActionBuilder, Unit> actionBuilder
)
Adds a new NavAction to the destination
argument
public final void argument(
@NonNull String name,
@NonNull Function1<@NonNull NavArgumentBuilder, Unit> argumentBuilder
)
Add a NavArgument to this destination.
argument
public final void argument(@NonNull String name, @NonNull NavArgument argument)
Add a NavArgument to this destination.
build
public @NonNull D build()
Build the NavDestination by calling Navigator.createDestination.
deepLink
public final void deepLink(
@NonNull Function1<@NonNull NavDeepLinkDslBuilder, Unit> navDeepLink
)
Add a deep link to this destination.
In addition to a direct Uri match, the following features are supported:
-
Uris without a scheme are assumed as http and https. For example,
www.example.comwill matchhttp://www.example.comandhttps://www.example.com. -
Placeholders in the form of
{placeholder_name}matches 1 or more characters. The String value of the placeholder will be available in the argumentsSavedStatewith a key of the same name. For example,http://www.example.com/users/{id}will matchhttp://www.example.com/users/4. -
The
.*wildcard can be used to match 0 or more characters.
| Parameters | |
|---|---|
@NonNull Function1<@NonNull NavDeepLinkDslBuilder, Unit> navDeepLink |
the NavDeepLink to be added to this destination |
deepLink
public final void deepLink(@NonNull NavDeepLink navDeepLink)
Add a deep link to this destination.
In addition to a direct Uri match, the following features are supported:
-
Uris without a scheme are assumed as http and https. For example,
www.example.comwill matchhttp://www.example.comandhttps://www.example.com. -
Placeholders in the form of
{placeholder_name}matches 1 or more characters. The String value of the placeholder will be available in the argumentsSavedStatewith a key of the same name. For example,http://www.example.com/users/{id}will matchhttp://www.example.com/users/4. -
The
.*wildcard can be used to match 0 or more characters.
| Parameters | |
|---|---|
@NonNull NavDeepLink navDeepLink |
the NavDeepLink to be added to this destination |
deepLink
public final void <T extends Object> deepLink(
@NonNull String basePath,
@NonNull Function1<@NonNull NavDeepLinkDslBuilder, Unit> navDeepLink
)
Add a deep link to this destination.
The arguments in T are expected to be identical (in name and type) to the arguments in the route from KClass that was used to construct this NavDestinationBuilder.
Extracts deeplink arguments from T and appends it to the basePath. See docs on the safe args version of NavDeepLink.Builder.setUriPattern for the final uriPattern's generation logic.
In addition to a direct Uri match, basePaths without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.
| Parameters | |
|---|---|
<T extends Object> |
The deepLink KClass to extract arguments from |
@NonNull String basePath |
The base uri path to append arguments onto |
@NonNull Function1<@NonNull NavDeepLinkDslBuilder, Unit> navDeepLink |
the NavDeepLink to be added to this destination |
| See also | |
|---|---|
setUriPattern |
for the final uriPattern's generation logic. |
deepLink
public final void <T extends Object> deepLink(
@NonNull KClass<@NonNull T> route,
@NonNull String basePath,
@NonNull Function1<@NonNull NavDeepLinkDslBuilder, Unit> navDeepLink
)
Add a deep link to this destination.
The arguments in route are expected to be identical (in name and type) to the arguments in the NavDestinationBuilder.route that was used to construct this NavDestinationBuilder.
Extracts deeplink arguments from route and appends it to the basePath. See docs on the safe args version of NavDeepLink.Builder.setUriPattern for the final uriPattern's generation logic.
In addition to a direct Uri match, basePaths without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.
| Parameters | |
|---|---|
@NonNull KClass<@NonNull T> route |
The deepLink KClass to extract arguments from |
@NonNull String basePath |
The base uri path to append arguments onto |
@NonNull Function1<@NonNull NavDeepLinkDslBuilder, Unit> navDeepLink |
the NavDeepLink to be added to this destination |
| See also | |
|---|---|
setUriPattern |
for the final uriPattern's generation logic. |
deepLinkSafeArgs
public final void <T extends Object> deepLinkSafeArgs(@NonNull String basePath)
Add a deep link to this destination.
The arguments in T are expected to be identical (in name and type) to the arguments in the route from KClass that was used to construct this NavDestinationBuilder.
Extracts deeplink arguments from T and appends it to the basePath. See docs on the safe args version of NavDeepLink.Builder.setUriPattern for the final uriPattern's generation logic.
In addition to a direct Uri match, basePaths without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.
| Parameters | |
|---|---|
<T extends Object> |
The deepLink KClass to extract arguments from |
@NonNull String basePath |
The base uri path to append arguments onto |
| See also | |
|---|---|
setUriPattern |
for the final uriPattern's generation logic. |
deepLinkSafeArgs
public final void <T extends Object> deepLinkSafeArgs(@NonNull String uriPattern)
Add a deep link to this destination.
In addition to a direct Uri match, the following features are supported:
-
Uris without a scheme are assumed as http and https. For example,
www.example.comwill matchhttp://www.example.comandhttps://www.example.com. -
Placeholders in the form of
{placeholder_name}matches 1 or more characters. The String value of the placeholder will be available in the argumentsSavedStatewith a key of the same name. For example,http://www.example.com/users/{id}will matchhttp://www.example.com/users/4. -
The
.*wildcard can be used to match 0 or more characters.
| See also | |
|---|---|
deepLink |
getLabel
public final CharSequence getLabel()
The descriptive label of the destination
setLabel
public final void setLabel(CharSequence label)
The descriptive label of the destination
Protected methods
getNavigator
protected final @NonNull Navigator<@NonNull D> getNavigator()
The navigator the destination that will be used in instantiateDestination to create the destination.
instantiateDestination
protected @NonNull D instantiateDestination()
Instantiate a new instance of D that will be passed to build.
By default, this calls Navigator.createDestination on navigator, but can be overridden to call a custom constructor, etc.