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

The destination to pop up to before navigating.

final int

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

final String

The destination to pop up to before navigating.

final KClass<@NonNull ?>

The destination to pop up to before navigating.

final Object

The destination to pop up to before navigating.

final boolean

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

final void
<T extends Object> popUpTo(
    @ExtensionFunctionType @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder
)

Pop up to a given destination before navigating.

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

Pop up to a given destination before navigating.

final void
<T extends Object> popUpTo(
    @NonNull T route,
    @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 activities.

getPopUpTo

Added in 1.0.0
public final int getPopUpTo()

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

getPopUpToId

public final int getPopUpToId()

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

getPopUpToRoute

public final String getPopUpToRoute()

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

getPopUpToRouteClass

public final KClass<@NonNull ?> getPopUpToRouteClass()

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

getPopUpToRouteObject

public final Object getPopUpToRouteObject()

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

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

public final void <T extends Object> popUpTo(
    @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
<T extends Object>

route from a KClass for the destination

@ExtensionFunctionType @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder

builder used to construct a popUpTo operation

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 <T extends Object> popUpTo(
    @NonNull T 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 T route

route from a Object for the destination

@ExtensionFunctionType @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder

builder used to construct a popUpTo operation

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

setPopUpTo

Added in 1.0.0
public final void setPopUpTo(int popUpTo)

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

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.