NavDestination.Companion

public static class NavDestination.Companion


Summary

Public methods

static final @NonNull Sequence<@NonNull NavDestination>

Provides a sequence of the NavDestination's hierarchy.

Protected methods

static final @NonNull Class<C>
<C extends Object> parseClassFromName(
    @NonNull Context context,
    @NonNull String name,
    @NonNull Class<C> expectedClassType
)

Parse the class associated with this destination from a raw name, generally extracted from the android:name attribute added to the destination's XML.

Public methods

getHierarchy

Added in 2.4.0
public static final @NonNull Sequence<@NonNull NavDestinationgetHierarchy(@NonNull NavDestination receiver)

Provides a sequence of the NavDestination's hierarchy. The hierarchy starts with this destination itself and is then followed by this destination's NavDestination.parent, then that graph's parent, and up the hierarchy until you've reached the root navigation graph.

Protected methods

parseClassFromName

Added in 2.4.0
protected static final @NonNull Class<C> <C extends Object> parseClassFromName(
    @NonNull Context context,
    @NonNull String name,
    @NonNull Class<C> expectedClassType
)

Parse the class associated with this destination from a raw name, generally extracted from the android:name attribute added to the destination's XML. This should be the class providing the visual representation of the destination that the user sees after navigating to this destination.

This method does name -> Class caching and should be strongly preferred over doing your own parsing if your Navigator supports the android:name attribute to give consistent behavior across all Navigators.

Parameters
@NonNull Context context

Context providing the package name for use with relative class names and the ClassLoader

@NonNull String name

Absolute or relative class name. Null names will be ignored.

@NonNull Class<C> expectedClassType

The expected class type

Returns
@NonNull Class<C>

The parsed class

Throws
kotlin.IllegalArgumentException

if the class is not found in the provided Context's ClassLoader or if the class is not of the expected type