CollectionNavType


abstract class CollectionNavType<T : Any?> : NavType


A NavType for Collection such as arrays, lists, maps.

Parameters
<T : Any?>

the type of the data that is supported by this NavType

Summary

Public constructors

<T : Any?> CollectionNavType(isNullableAllowed: Boolean)

Public functions

abstract T

Create and return an empty collection of type T

abstract List<String>

Serialize a value of this NavType into a list of String.

Inherited functions

From androidx.navigation.NavType
abstract operator T?
get(bundle: SavedState, key: String)

Get a value of this type from the bundle

abstract T

Parse a value of this type from a String.

open T
parseValue(value: String, previousValue: T)

Parse a value of this type from a String and then combine that parsed value with the given previousValue of the same type to provide a new value that contains both the new and previous value.

abstract Unit
put(bundle: SavedState, key: String, value: T)

Put a value of this type in the bundle

open String
serializeAsValue(value: T)

Serialize a value of this NavType into a String.

open String
open Boolean
valueEquals(value: T, other: T)

Compares two values of type T and returns true if values are equal.

Inherited properties

From androidx.navigation.NavType
open Boolean

Check if an argument with this type can hold a null value.

open String

The name of this type.

Public constructors

CollectionNavType

<T : Any?> CollectionNavType(isNullableAllowed: Boolean)
Parameters
<T : Any?>

the type of the data that is supported by this NavType

isNullableAllowed: Boolean

whether the argument of this type can hold a null value

Public functions

emptyCollection

Added in 2.8.0
abstract fun emptyCollection(): T

Create and return an empty collection of type T

For example, T of type List should return emptyList().

serializeAsValues

Added in 2.8.0
abstract fun serializeAsValues(value: T): List<String>

Serialize a value of this NavType into a list of String.

Each element in the collection should be converted to an individual String element of the returned list.

Note: Elements should be encoded with Uri.encode

Parameters
value: T

a value of this NavType

Returns
List<String>

List containing encoded and serialized String representation of value