NavOptionsBuilder


@NavOptionsDsl
public final class NavOptionsBuilder


DSL for constructing a new NavOptions

Summary

Public constructors

Public methods

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 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
<T extends Object> popUpTo(
    @NonNull KClass<@NonNull T> route,
    @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
setPopUpToRoute(String popUpToRoute)
final void
setPopUpToRouteClass(KClass<@NonNull ?> popUpToRouteClass)
final void
setPopUpToRouteObject(Object popUpToRouteObject)
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 2.4.0
public NavOptionsBuilder()
Added in 2.4.0
public NavOptionsBuilder()

Public methods

getLaunchSingleTop

Added in 2.4.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.

getPopUpToRoute

Added in 2.4.0
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

Added in 2.8.0
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

Added in 2.8.0
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

Added in 2.4.0
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 2.9.0-alpha07
public final void <T extends Object> popUpTo(
    @NonNull KClass<@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 KClass<@NonNull T> route

the KClass of the destination T

@ExtensionFunctionType @NonNull Function1<@NonNull PopUpToBuilderUnit> popUpToBuilder

builder used to construct a popUpTo operation

popUpTo

Added in 2.8.0
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

Added in 2.4.0
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 2.4.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.

setPopUpToRoute

public final void setPopUpToRoute(String popUpToRoute)

setPopUpToRouteClass

public final void setPopUpToRouteClass(KClass<@NonNull ?> popUpToRouteClass)

setPopUpToRouteObject

public final void setPopUpToRouteObject(Object popUpToRouteObject)

setRestoreState

Added in 2.4.0
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.