Distance

public final class Distance
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.car.cluster.navigation.Distance


Distance along the planned route between relevant points in the navigation

Summary

Nested classes

enum Distance.Unit

Possible units used to display this distance. 

Public constructors

Distance(int meters, String displayValue, Distance.Unit displayUnit)

Creates a distance.

Public methods

boolean equals(Object o)
Distance.Unit getDisplayUnit()

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

String getDisplayValue()

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 getMeters()

Returns the distance in meters.

int hashCode()
String toString()

Inherited methods

Public constructors

Distance

public Distance (int meters, 
                String displayValue, 
                Distance.Unit displayUnit)

Creates a distance.

Parameters
meters int: distance in meters.

displayValue String: distance measured in displayUnit.

displayUnit Distance.Unit: unit to be used when displaying this distance

Public methods

equals

public boolean equals (Object o)

Parameters
o Object

Returns
boolean

getDisplayUnit

public Distance.Unit getDisplayUnit ()

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).

Returns
Distance.Unit

getDisplayValue

public String getDisplayValue ()

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 Distance.Unit.UNKNOWN.

Returns
String

getMeters

public int getMeters ()

Returns the distance in meters.

Returns
int

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String