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

Trip.Builder

public static final class Trip.Builder
extends Object

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


A builder of Trip.

Summary

Public constructors

Builder()

Constructs an empty Trip.Builder instance.

Public methods

Trip.Builder addDestination(Destination destination, TravelEstimate destinationTravelEstimate)

Adds a destination to the trip.

Trip.Builder addStep(Step step, TravelEstimate stepTravelEstimate)

Adds a step to the trip.

Trip build()

Constructs the Trip defined by this builder.

Trip.Builder setCurrentRoad(CharSequence currentRoad)

Sets a description of the current road.

Trip.Builder setLoading(boolean isLoading)

Sets whether the Trip is in a loading state.

Inherited methods

Public constructors

Builder

public Builder ()

Constructs an empty Trip.Builder instance.

Public methods

addDestination

public Trip.Builder addDestination (Destination destination, 
                TravelEstimate destinationTravelEstimate)

Adds a destination to the trip.

Destinations must be added in order of arrival. A destination is not required. Display surfaces may or may not use the destination and if multiple destinations are added the display may only show information about the first destination.

For every destination added, a corresponding TravelEstimate must be provided. Display surfaces may or may not use the destination travel estimate and if multiple destination travel estimates are added the display may only show information about the first destination travel estimate.

Parameters
destination Destination

destinationTravelEstimate TravelEstimate

Returns
Trip.Builder

Throws
NullPointerException if step or stepTravelEstimate are null

addStep

public Trip.Builder addStep (Step step, 
                TravelEstimate stepTravelEstimate)

Adds a step to the trip.

Steps must be added in order of arrival. A step is not required. Display surfaces may or may not use the step and if multiple steps are added the display may only show information about the first step.

For every step added, a corresponding TravelEstimate must be provided. Display surfaces may or may not use the step travel estimate and if multiple step travel estimates are added the display may only show information about the first step travel estimate.

Parameters
step Step

stepTravelEstimate TravelEstimate

Returns
Trip.Builder

Throws
NullPointerException if step or stepTravelEstimate are null

build

public Trip build ()

Constructs the Trip defined by this builder.

Returns
Trip

setCurrentRoad

public Trip.Builder setCurrentRoad (CharSequence currentRoad)

Sets a description of the current road.

Spans are not supported in the input string.

Parameters
currentRoad CharSequence

Returns
Trip.Builder

Throws
NullPointerException if currentRoad is null

See also:

setLoading

public Trip.Builder setLoading (boolean isLoading)

Sets whether the Trip is in a loading state.

If set to true, the UI may show a loading indicator, and adding any steps or step travel estimates will throw an IllegalArgumentException.

Parameters
isLoading boolean

Returns
Trip.Builder