NavigationTemplate.Builder

public static final class NavigationTemplate.Builder
extends Object

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


A builder of NavigationTemplate.

Summary

Public constructors

Builder()

Constructs an empty NavigationTemplate.Builder instance.

Public methods

NavigationTemplate build()

Constructs the NavigationTemplate defined by this builder.

NavigationTemplate.Builder setActionStrip(ActionStrip actionStrip)

Sets an ActionStrip with a list of template-scoped actions for this template.

NavigationTemplate.Builder setBackgroundColor(CarColor backgroundColor)

Sets the background color to use for the navigation information.

NavigationTemplate.Builder setDestinationTravelEstimate(TravelEstimate destinationTravelEstimate)

Sets the TravelEstimate to the final destination.

NavigationTemplate.Builder setMapActionStrip(ActionStrip actionStrip)

Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.

NavigationTemplate.Builder setNavigationInfo(NavigationTemplate.NavigationInfo navigationInfo)

Sets the navigation information to display on the template.

NavigationTemplate.Builder setPanModeListener(PanModeListener panModeListener)

Sets a PanModeListener that notifies when the user enters and exits the pan mode.

Inherited methods

Public constructors

Builder

public Builder ()

Constructs an empty NavigationTemplate.Builder instance.

Public methods

build

public NavigationTemplate build ()

Constructs the NavigationTemplate defined by this builder.

Returns
NavigationTemplate

Throws
IllegalStateException if an ActionStrip is not set on this template

setActionStrip

public NavigationTemplate.Builder setActionStrip (ActionStrip actionStrip)

Sets an ActionStrip with a list of template-scoped actions for this template.

Requirements

Besides Action.APP_ICON and Action.BACK, this template requires at least 1 and up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, only one can contain a title as set via Action.Builder.setTitle(CarText). Otherwise, only Actions with icons are allowed.

Parameters
actionStrip ActionStrip

Returns
NavigationTemplate.Builder

Throws
IllegalArgumentException if actionStrip does not meet the template's requirements
NullPointerException if actionStrip is null

setBackgroundColor

public NavigationTemplate.Builder setBackgroundColor (CarColor backgroundColor)

Sets the background color to use for the navigation information.

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.

Parameters
backgroundColor CarColor

Returns
NavigationTemplate.Builder

setDestinationTravelEstimate

public NavigationTemplate.Builder setDestinationTravelEstimate (TravelEstimate destinationTravelEstimate)

Sets the TravelEstimate to the final destination.

Parameters
destinationTravelEstimate TravelEstimate

Returns
NavigationTemplate.Builder

Throws
IllegalArgumentException if the TravelEstimate's remaining time is TravelEstimate.REMAINING_TIME_UNKNOWN or less than zero
NullPointerException if destinationTravelEstimate is null

setMapActionStrip

public NavigationTemplate.Builder setMapActionStrip (ActionStrip actionStrip)

Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.

The host will draw the buttons in an area that is associated with map controls.

Requirements

This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via Action.Builder.setIcon(CarIcon) are allowed.

Parameters
actionStrip ActionStrip

Returns
NavigationTemplate.Builder

Throws
IllegalArgumentException if actionStrip does not meet the template's requirements
NullPointerException if actionStrip is null

setNavigationInfo

public NavigationTemplate.Builder setNavigationInfo (NavigationTemplate.NavigationInfo navigationInfo)

Sets the navigation information to display on the template.

Unless set with this method, navigation info won't be displayed on the template.

Parameters
navigationInfo NavigationTemplate.NavigationInfo

Returns
NavigationTemplate.Builder

Throws
NullPointerException if navigationInfo is null

setPanModeListener

public NavigationTemplate.Builder setPanModeListener (PanModeListener panModeListener)

Sets a PanModeListener that notifies when the user enters and exits the pan mode.

Parameters
panModeListener PanModeListener

Returns
NavigationTemplate.Builder

Throws
NullPointerException if panModeListener is null