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 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(@ExtensionFunctionType Function1<AnimBuilderUnit> animBuilder)

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

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

Pop up to a given destination before navigating.

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

Pop up to a given destination before navigating.

Public fields

launchSingleTop

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

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

public final @IdRes int popUpToId

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

popUpToRoute

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

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

public final void anim(@ExtensionFunctionType Function1<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

public final void popUpTo(
    @IdRes int id,
    @ExtensionFunctionType Function1<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

public final void popUpTo(
    String route,
    @ExtensionFunctionType Function1<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
String route

route for the destination

@ExtensionFunctionType Function1<PopUpToBuilderUnit> popUpToBuilder

builder used to construct a popUpTo operation