NavOptionsBuilder

@NavOptionsDsl public final class NavOptionsBuilder


DSL for constructing a new NavOptions

Summary

Public fields

final boolean

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

final int

This field is deprecated. Use the popUpToId property.

final @IdRes int

Returns the current destination that the builder will pop up to.

final @Nullable String

Pop up to a given destination before navigating.

final boolean

Whether this navigation action should restore any state previously saved by PopUpToBuilder.saveState or the popUpToSaveState attribute.

Public constructors

Public methods

final void
anim(@NonNull Function1<@NonNull AnimBuilderUnit> animBuilder)

Sets any custom Animation or Animator resources that should be used.

final void
popUpTo(
    @IdRes int id,
    @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder
)

Pop up to a given destination before navigating.

final void
popUpTo(
    @NonNull String route,
    @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder
)

Pop up to a given destination before navigating.

Public fields

launchSingleTop

@NonNull
public final boolean launchSingleTop

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

This functions similarly to how android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP works with activites.

popUpTo

@NonNull
public final int popUpTo

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

popUpToId

@IdRes
@NonNull
public final @IdRes int popUpToId

Returns the current destination that the builder will pop up to.

popUpToRoute

@Nullable
public final @Nullable String popUpToRoute

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

restoreState

@NonNull
public final boolean restoreState

Whether this navigation action should restore any state previously saved by PopUpToBuilder.saveState or the popUpToSaveState attribute. If no state was previously saved with the destination ID being navigated to, this has no effect.

Public constructors

public final NavOptionsBuilder()

Public methods

anim

@NonNull
public final void anim(@NonNull Function1<@NonNull AnimBuilderUnit> animBuilder)

Sets any custom Animation or Animator resources that should be used.

Note: Animator resources are not supported for navigating to a new Activity

popUpTo

@NonNull
public final void popUpTo(
    @IdRes int id,
    @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder
)

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

popUpTo

@NonNull
public final void popUpTo(
    @NonNull String route,
    @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder
)

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

Parameters
@NonNull String route

route for the destination

@NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder

builder used to construct a popUpTo operation