# Trip.Builder

# Trip.Builder

Artifact:[androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app)  
[View Source](https://cs.android.com/search?q=file:androidx/car/app/navigation/model/Trip.java+class:androidx.car.app.navigation.model.Trip.Builder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder "View this page in Java")

<br />

```
class Trip.Builder
```

<br />

*** ** * ** ***

A builder of[Trip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip).

## Summary

|                                                                                                                   ### Public constructors                                                                                                                   |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder#Builder())`()` Constructs an empty[Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder)instance. |

|                                             ### Public functions                                              |
|---------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Trip.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder) | [addDestination](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder#addDestination(androidx.car.app.navigation.model.Destination,androidx.car.app.navigation.model.TravelEstimate))`(` ` destination: `[Destination](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Destination)`,` ` destinationTravelEstimate: `[TravelEstimate](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate) `)` Adds a destination to the trip. |
| [Trip.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder) | [addStep](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder#addStep(androidx.car.app.navigation.model.Step,androidx.car.app.navigation.model.TravelEstimate))`(step: `[Step](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Step)`, stepTravelEstimate: `[TravelEstimate](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/TravelEstimate)`)` Adds a step to the trip.                                                                 |
| [Trip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip)                 | [build](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder#build())`()` Constructs the[Trip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip)defined by this builder.                                                                                                                                                                                                                                                                                               |
| [Trip.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder) | [setCurrentRoad](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder#setCurrentRoad(java.lang.CharSequence))`(currentRoad: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Sets a description of the current road.                                                                                                                                                                                                                                      |
| [Trip.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder) | [setLoading](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder#setLoading(boolean))`(isLoading: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Sets whether the[Trip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip)is in a loading state.                                                                                                                                                                              |

## Public constructors

### Builder

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
Builder()
```

Constructs an empty[Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip.Builder)instance.  

## Public functions

### addDestination

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun addDestination(
    destination: Destination,
    destinationTravelEstimate: TravelEstimate
): Trip.Builder
```

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](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/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.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|------------------------------------------|
| [java.lang.NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) | if`step`or`stepTravelEstimate`are` null` |

### addStep

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun addStep(step: Step, stepTravelEstimate: TravelEstimate): Trip.Builder
```

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](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/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.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|------------------------------------------|
| [java.lang.NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) | if`step`or`stepTravelEstimate`are` null` |

### build

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun build(): Trip
```

Constructs the[Trip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/Trip)defined by this builder.  

### setCurrentRoad

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun setCurrentRoad(currentRoad: CharSequence): Trip.Builder
```

Sets a description of the current road.

Spans are not supported in the input string and will be ignored.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|-------------------------|
| [java.lang.NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) | if`currentRoad`is`null` |

|                                         See also                                         |
|------------------------------------------------------------------------------------------|---|
| [CarText](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText) |   |

### setLoading

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun setLoading(isLoading: Boolean): Trip.Builder
```

Sets whether the[Trip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/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](https://developer.android.com/reference/java/lang/IllegalArgumentException.html).