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

RoutingInfo.Builder

public static final class RoutingInfo.Builder
extends Object

java.lang.Object
   ↳ com.google.android.libraries.car.app.navigation.model.RoutingInfo.Builder


A builder of RoutingInfo.

Summary

Public methods

RoutingInfo build()

Constructs the RoutingInfo defined by this builder.

RoutingInfo.Builder setCurrentStep(Step currentStep, Distance currentDistance)

Sets the current Step and Distance to display in the template.

RoutingInfo.Builder setIsLoading(boolean isLoading)

Sets whether the RoutingInfo is in a loading state.

RoutingInfo.Builder setJunctionImage(CarIcon junctionImage)

Sets an image of a junction for the maneuver or null to not show a junction image.

RoutingInfo.Builder setNextStep(Step nextStep)

Sets the next Step or null to not display it.

Inherited methods

Public methods

build

public RoutingInfo build ()

Constructs the RoutingInfo defined by this builder.

Requirements

The RoutingInfo can be in a loading state by passing true to setIsLoading(boolean), in which case no other fields may be set. Otherwise, the current step and distance must be set. If the lane information is set with Step.Builder.addLane(Lane), then the lane image must also be set with Step.Builder.setLanesImage(CarIcon).

Returns
RoutingInfo

Throws
IllegalStateException if the RoutingInfo does not meet the template's requirements.

setCurrentStep

public RoutingInfo.Builder setCurrentStep (Step currentStep, 
                Distance currentDistance)

Sets the current Step and Distance to display in the template.

A Step with a Maneuver of type Maneuver.TYPE_UNKNOWN will shown here with the given icon.

Image Sizing Guidance

Images in the cue of the Step object, set with Step.Builder.setCue(CharSequence), can contain image spans. If necessary, those images in the spans will be scaled down to fit within a 108 x 36 dp bounding box, while preserving their aspect ratio.

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

Parameters
currentStep Step

currentDistance Distance

Returns
RoutingInfo.Builder

setIsLoading

public RoutingInfo.Builder setIsLoading (boolean isLoading)

Sets whether the RoutingInfo is in a loading state.

If set to true, the UI will show a loading indicator, and adding any other routing info will throw an IllegalArgumentException. The caller is expected to call Screen.invalidate() and send the new template content to the host once the data is ready. If set to false, the UI shows the actual routing info.

Parameters
isLoading boolean

Returns
RoutingInfo.Builder

See also:

setJunctionImage

public RoutingInfo.Builder setJunctionImage (CarIcon junctionImage)

Sets an image of a junction for the maneuver or null to not show a junction image.

For example, a photo-realistic view of the upcoming junction that the driver can see when executing the maneuver.

Image Sizing Guidance

The image may be scaled down to fit a rectangle of 320 x 200 dp while preserving the aspect ratio. On smaller screens the junction image may result in the hiding of the Lanes, TravelEstimate or next Step. The aspect ratio should be greater than or equal to 1.6 in order to fit the horizontal space fully.

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

Parameters
junctionImage CarIcon

Returns
RoutingInfo.Builder

setNextStep

public RoutingInfo.Builder setNextStep (Step nextStep)

Sets the next Step or null to not display it.

Image Sizing Guidance

Images in the cue of the Step object, set with Step.Builder.setCue(CharSequence), can contain image spans. If necessary, those images in the spans will be scaled down to fit within a 108 x 32 dp bounding box, while preserving their aspect ratio.

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

Parameters
nextStep Step

Returns
RoutingInfo.Builder