TravelEstimate.Builder


public final class TravelEstimate.Builder


A builder of TravelEstimate.

Summary

Public constructors

Builder(
    @NonNull Distance remainingDistance,
    @NonNull DateTimeWithZone arrivalTimeAtDestination
)

Constructs a new builder of TravelEstimate.

@RequiresApi(value = 26)
Builder(
    @NonNull Distance remainingDistance,
    @NonNull ZonedDateTime arrivalTimeAtDestination
)

Constructs a new builder of TravelEstimate.

Public methods

@NonNull TravelEstimate

Constructs the TravelEstimate defined by this builder.

@NonNull TravelEstimate.Builder
setRemainingDistanceColor(@NonNull CarColor remainingDistanceColor)

Sets the color of the remaining distance text.

@NonNull TravelEstimate.Builder
@RequiresApi(value = 26)
setRemainingTime(@NonNull Duration remainingTime)

Sets the estimated time remaining until arriving at the destination.

@NonNull TravelEstimate.Builder
setRemainingTimeColor(@NonNull CarColor remainingTimeColor)

Sets the color of the remaining time text.

@NonNull TravelEstimate.Builder
setRemainingTimeSeconds(@IntRange(from = "-1") long remainingTimeSeconds)

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

@NonNull TravelEstimate.Builder
@RequiresCarApi(value = 5)
setTripIcon(@NonNull CarIcon tripIcon)

Sets a CarIcon that is associated with the current TravelEstimate

@NonNull TravelEstimate.Builder
@RequiresCarApi(value = 5)
setTripText(@NonNull CarText tripText)

Sets the trip text.

Public constructors

Builder

Added in 1.0.0
public Builder(
    @NonNull Distance remainingDistance,
    @NonNull DateTimeWithZone arrivalTimeAtDestination
)

Constructs a new builder of TravelEstimate.

Parameters
@NonNull Distance remainingDistance

The estimated remaining Distance until arriving at the destination

@NonNull DateTimeWithZone arrivalTimeAtDestination

The arrival time with the time zone information provided for the destination

Throws
java.lang.NullPointerException

if remainingDistance or arrivalTimeAtDestination are null

Builder

Added in 1.0.0
@RequiresApi(value = 26)
public Builder(
    @NonNull Distance remainingDistance,
    @NonNull ZonedDateTime arrivalTimeAtDestination
)

Constructs a new builder of TravelEstimate.

Parameters
@NonNull Distance remainingDistance

The estimated remaining Distance until arriving at the destination

@NonNull ZonedDateTime arrivalTimeAtDestination

The arrival time with the time zone information provided for the destination

Throws
java.lang.NullPointerException

if remainingDistance or arrivalTimeAtDestination are null

Public methods

build

Added in 1.0.0
public @NonNull TravelEstimate build()

Constructs the TravelEstimate defined by this builder.

setRemainingDistanceColor

Added in 1.0.0
public @NonNull TravelEstimate.Builder setRemainingDistanceColor(@NonNull CarColor remainingDistanceColor)

Sets the color of the remaining distance text.

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.

If not set, DEFAULT will be used.

Custom colors created with createCustom are not supported.

Throws
java.lang.IllegalArgumentException

if remainingDistanceColor is not supported

java.lang.NullPointerException

if remainingDistanceColor is null

setRemainingTime

Added in 1.0.0
@RequiresApi(value = 26)
public @NonNull TravelEstimate.Builder setRemainingTime(@NonNull Duration remainingTime)

Sets the estimated time remaining until arriving at the destination.

If not set, REMAINING_TIME_UNKNOWN will be used.

Throws
java.lang.IllegalArgumentException

if remainingTime is a negative duration but not REMAINING_TIME_UNKNOWN

java.lang.NullPointerException

if remainingTime is null

setRemainingTimeColor

Added in 1.0.0
public @NonNull TravelEstimate.Builder setRemainingTimeColor(@NonNull CarColor remainingTimeColor)

Sets the color of the remaining time text.

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.

If not set, DEFAULT will be used.

Custom colors created with createCustom are not supported.

Throws
java.lang.IllegalArgumentException

if remainingTimeColor is not supported

java.lang.NullPointerException

if remainingTimecolor is null

setRemainingTimeSeconds

Added in 1.0.0
public @NonNull TravelEstimate.Builder setRemainingTimeSeconds(@IntRange(from = "-1") long remainingTimeSeconds)

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

If not set, REMAINING_TIME_UNKNOWN will be used.

Note that REMAINING_TIME_UNKNOWN may not be supported depending on where the TravelEstimate is used. See the documentation of where TravelEstimate is used for any restrictions that might apply.

Throws
java.lang.IllegalArgumentException

if remainingTimeSeconds is a negative value but not REMAINING_TIME_UNKNOWN

setTripIcon

Added in 1.3.0
@RequiresCarApi(value = 5)
public @NonNull TravelEstimate.Builder setTripIcon(@NonNull CarIcon tripIcon)

Sets a CarIcon that is associated with the current TravelEstimate

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

Throws
java.lang.NullPointerException

if tripIcon is null

setTripText

Added in 1.3.0
@RequiresCarApi(value = 5)
public @NonNull TravelEstimate.Builder setTripText(@NonNull CarText tripText)

Sets the trip text.

A text that provides additional information about this TravelEstimate, such as drop off/pick up information, and battery level, that should be displayed on the screen alongside the remaining distance and time.

For example "Pick up Alice", "Drop off Susan", or "Battery Level is Low".

Throws
java.lang.NullPointerException

if tripText is null

java.lang.IllegalArgumentException

if tripText contains unsupported spans

See also
CarText