Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Distance

class Distance : VersionedParcelable
kotlin.Any
   ↳ androidx.car.cluster.navigation.Distance

Distance along the planned route between relevant points in the navigation

Summary

Nested classes

Possible units used to display this distance.

Public constructors

<init>(meters: Int, @NonNull displayValue: String, @NonNull displayUnit: Distance.Unit)

Creates a distance.

Public methods

Boolean
equals(other: Any?)

Distance.Unit

Returns the distance unit (adjusted to the current user's locale and/or location).

String

Returns the distance measured in the unit indicated at getDisplayUnit(), already internationalized and ready for display, or empty if not distance value was provided.

Int

Returns the distance in meters.

Int

String

Public constructors

<init>

Distance(meters: Int, @NonNull displayValue: String, @NonNull displayUnit: Distance.Unit)

Creates a distance.

Parameters
meters Int: distance in meters.
displayValue Int: distance measured in displayUnit.
displayUnit Int: unit to be used when displaying this distance

Public methods

equals

fun equals(other: Any?): Boolean

getDisplayUnit

@NonNull fun getDisplayUnit(): Distance.Unit

Returns the distance unit (adjusted to the current user's locale and/or location). This field would mirror the distance unit displayed by the producer in its own UI, and it should be used for display only (no unit transformation should be applied).

getDisplayValue

@NonNull fun getDisplayValue(): String

Returns the distance measured in the unit indicated at getDisplayUnit(), already internationalized and ready for display, or empty if not distance value was provided. In the later case, the consumer shouldn't display this distance to the driver.

This distance is for display only (it might be a rounded representation of the actual distance) and it should mirror the distance displayed by the producer in its own UI.

For example, a distance of 1.2 km in ES_es locale would be represented as displayValue = "1,2" and displayUnit = KILOMETERS). This field is only relevant if getDisplayUnit() is not Unit#UNKNOWN.

getMeters

fun getMeters(): Int

Returns the distance in meters.

hashCode

fun hashCode(): Int

toString

fun toString(): String