NavDestination.Companion
public static class NavDestination.Companion
Summary
Public methods |
|
|---|---|
static final @NonNull Sequence<@NonNull NavDestination> |
getHierarchy(@NonNull NavDestination receiver)Provides a sequence of the NavDestination's hierarchy. |
static final boolean |
<T extends Object> hasRoute(@NonNull NavDestination receiver) |
static final boolean |
Checks if the NavDestination's route was generated from |
Protected methods |
|
|---|---|
static final @NonNull Class<C> |
<C extends Object> parseClassFromName(Parse the class associated with this destination from a raw name, generally extracted from the |
Public methods
getHierarchy
public static final @NonNull Sequence<@NonNull NavDestination> getHierarchy(@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.
hasRoute
public static final boolean <T extends Object> hasRoute(@NonNull NavDestination receiver)
Checks if the NavDestination's route was generated from T
Returns true if equal, false otherwise.
| Parameters | |
|---|---|
<T extends Object> |
the route from KClass |
Protected methods
parseClassFromName
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 |
| 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 |