NavOptionsBuilder

@NavOptionsDsl
public final class NavOptionsBuilder


DSL for constructing a new NavOptions

Summary

Public constructors

Public methods

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

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

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

Pop up to a given destination before navigating.

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

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

Pop up to a given destination before navigating.

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

Pop up to a given destination before navigating.

final void
setLaunchSingleTop(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).

final void
setPopUpTo(int popUpTo)

This method is deprecated. Use the popUpTo function and passing in the id.

final void
setRestoreState(boolean restoreState)

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

Public constructors

Added in 1.0.0
public NavOptionsBuilder()

Public methods

anim

Added in 1.0.0
public final void anim(
    @ExtensionFunctionType @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

getLaunchSingleTop

Added in 1.0.0
public final boolean getLaunchSingleTop()

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.

getPopUpTo

Added in 1.0.0
public final int getPopUpTo()

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

getPopUpToId

public final int getPopUpToId()

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

getPopUpToRoute

public final String getPopUpToRoute()

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

getRestoreState

public final boolean getRestoreState()

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.

popUpTo

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

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

@ExtensionFunctionType @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder

builder used to construct a popUpTo operation

setLaunchSingleTop

Added in 1.0.0
public final void setLaunchSingleTop(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.

setPopUpTo

Added in 1.0.0
public final void setPopUpTo(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.

setRestoreState

public final void setRestoreState(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.