Android 12 Developer Preview is here! Try it out, and give us your feedback!

TravelEstimate.Builder

public static final class TravelEstimate.Builder
extends Object

java.lang.Object
   ↳ androidx.car.app.navigation.model.TravelEstimate.Builder


A builder of TravelEstimate.

Summary

Public constructors

Builder(Distance remainingDistance, DateTimeWithZone arrivalTimeAtDestination)

Constructs a new builder of TravelEstimate.

Builder(Distance remainingDistance, ZonedDateTime arrivalTimeAtDestination)

Constructs a new builder of TravelEstimate.

Public methods

TravelEstimate build()

Constructs the TravelEstimate defined by this builder.

TravelEstimate.Builder setRemainingDistanceColor(CarColor remainingDistanceColor)

Sets the color of the remaining distance text.

TravelEstimate.Builder setRemainingTime(Duration remainingTime)

Sets the estimated time remaining until arriving at the destination.

TravelEstimate.Builder setRemainingTimeColor(CarColor remainingTimeColor)

Sets the color of the remaining time text.

TravelEstimate.Builder setRemainingTimeSeconds(long remainingTimeSeconds)

Sets the estimated time remaining until arriving at the destination, in seconds.

Inherited methods

Public constructors

Builder

public Builder (Distance remainingDistance, 
                DateTimeWithZone arrivalTimeAtDestination)

Constructs a new builder of TravelEstimate.

Parameters
remainingDistance Distance: The estimated remaining Distance until arriving at the destination

arrivalTimeAtDestination DateTimeWithZone: The arrival time with the time zone information provided for the destination

Throws
NullPointerException if remainingDistance or arrivalTimeAtDestination are null

Builder

public Builder (Distance remainingDistance, 
                ZonedDateTime arrivalTimeAtDestination)

Constructs a new builder of TravelEstimate.

Parameters
remainingDistance Distance: The estimated remaining Distance until arriving at the destination

arrivalTimeAtDestination ZonedDateTime: The arrival time with the time zone information provided for the destination

Throws
NullPointerException if remainingDistance or arrivalTimeAtDestination are null

Public methods

build

public TravelEstimate build ()

Constructs the TravelEstimate defined by this builder.

Returns
TravelEstimate

setRemainingDistanceColor

public TravelEstimate.Builder setRemainingDistanceColor (CarColor remainingDistanceColor)

Sets the color of the remaining distance text.

The host may ignore this color depending on the capabilities of the target screen.

If not set, CarColor.DEFAULT will be used.

Custom colors created with CarColor.createCustom(int, int) are not supported.

Parameters
remainingDistanceColor CarColor

Returns
TravelEstimate.Builder

Throws
IllegalArgumentException if remainingDistanceColor is not supported
NullPointerException if remainingDistanceColor is null

setRemainingTime

public TravelEstimate.Builder setRemainingTime (Duration remainingTime)

Sets the estimated time remaining until arriving at the destination.

If not set, TravelEstimate.REMAINING_TIME_UNKNOWN will be used.

Parameters
remainingTime Duration

Returns
TravelEstimate.Builder

Throws
IllegalArgumentException if remainingTime is a negative duration but not TravelEstimate.REMAINING_TIME_UNKNOWN
NullPointerException if remainingTime is null

setRemainingTimeColor

public TravelEstimate.Builder setRemainingTimeColor (CarColor remainingTimeColor)

Sets the color of the remaining time text.

The host may ignore this color depending on the capabilities of the target screen.

If not set, CarColor.DEFAULT will be used.

Custom colors created with CarColor.createCustom(int, int) are not supported.

Parameters
remainingTimeColor CarColor

Returns
TravelEstimate.Builder

Throws
IllegalArgumentException if remainingTimeColor is not supported
NullPointerException if remainingTimecolor is null

setRemainingTimeSeconds

public TravelEstimate.Builder setRemainingTimeSeconds (long remainingTimeSeconds)

Sets the estimated time remaining until arriving at the destination, in seconds.

If not set, TravelEstimate.REMAINING_TIME_UNKNOWN will be used.

Parameters
remainingTimeSeconds long

Value is -1 or greater.

Returns
TravelEstimate.Builder

Throws
IllegalArgumentException if remainingTimeSeconds is a negative value but not TravelEstimate.REMAINING_TIME_UNKNOWN