RoutePreviewNavigationTemplate.Builder

public static final class RoutePreviewNavigationTemplate.Builder
extends Object

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


A builder of RoutePreviewNavigationTemplate.

Summary

Public constructors

Builder()

Constructs an empty RoutePreviewNavigationTemplate.Builder instance.

Public methods

RoutePreviewNavigationTemplate build()

Constructs the template defined by this builder.

RoutePreviewNavigationTemplate.Builder setActionStrip(ActionStrip actionStrip)

Sets the ActionStrip for this template, or null to not display an ActionStrip.

RoutePreviewNavigationTemplate.Builder setHeaderAction(Action headerAction)

Sets the Action that will be displayed in the header of the template, or null to not display an action.

RoutePreviewNavigationTemplate.Builder setItemList(ItemList itemList)

Sets an ItemList to show route options in a list view along with the map.

RoutePreviewNavigationTemplate.Builder setLoading(boolean isLoading)

Sets whether the template is in a loading state.

RoutePreviewNavigationTemplate.Builder setNavigateAction(Action navigateAction)

Sets the Action to allow users to request navigation using the currently selected route.

RoutePreviewNavigationTemplate.Builder setTitle(CharSequence title)

Sets the title of the template.

Inherited methods

Public constructors

Builder

public Builder ()

Constructs an empty RoutePreviewNavigationTemplate.Builder instance.

Public methods

build

public RoutePreviewNavigationTemplate build ()

Constructs the template defined by this builder.

Requirements

Either a header Action or title must be set on the template.

Returns
RoutePreviewNavigationTemplate

Throws
IllegalStateException if the template is in a loading state but the list is set or vice versa, if the template is not loading and the navigation action is not set, or if the template does not have either a title or header Action set

setActionStrip

public RoutePreviewNavigationTemplate.Builder setActionStrip (ActionStrip actionStrip)

Sets the ActionStrip for this template, or null to not display an ActionStrip.

Unless set with this method, the template will not have an action strip.

Requirements

This template allows up to 2 Actions in its ActionStrip. Of the 2 allowed Actions, one of them can contain a title as set via Action.Builder.setTitle(CarText). Otherwise, only Actions with icons are allowed.

Parameters
actionStrip ActionStrip

Returns
RoutePreviewNavigationTemplate.Builder

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

setHeaderAction

public RoutePreviewNavigationTemplate.Builder setHeaderAction (Action headerAction)

Sets the Action that will be displayed in the header of the template, or null to not display an action.

Unless set with this method, the template will not have a header action.

Requirements

This template only supports either one of Action.APP_ICON and Action.BACK as a header Action.

Parameters
headerAction Action

Returns
RoutePreviewNavigationTemplate.Builder

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

setItemList

public RoutePreviewNavigationTemplate.Builder setItemList (ItemList itemList)

Sets an ItemList to show route options in a list view along with the map.

Requirements

This template allows up to 3 Rows in the ItemList. The host will ignore any items over that limit. The list must have an OnClickListener set. Each Row can add up to 2 lines of texts via Row.Builder.addText(CarText) and cannot contain a Toggle.

Images of type Row.IMAGE_TYPE_LARGE are not allowed in this template.

All rows must have either a DistanceSpan or a DurationSpan attached to either its title or texts, to indicate an estimate trip distance or duration for the route it represents. Where in the title or text these spans are attached to is up to the app.

Parameters
itemList ItemList

Returns
RoutePreviewNavigationTemplate.Builder

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

setLoading

public RoutePreviewNavigationTemplate.Builder setLoading (boolean isLoading)

Sets whether the template is in a loading state.

If set to true, the UI will show a loading indicator where the list content would be otherwise. The caller is expected to call Screen.invalidate() and send the new template content to the host once the data is ready.

Parameters
isLoading boolean

Returns
RoutePreviewNavigationTemplate.Builder

setNavigateAction

public RoutePreviewNavigationTemplate.Builder setNavigateAction (Action navigateAction)

Sets the Action to allow users to request navigation using the currently selected route.

This should not be null if the template is not in a loading state (see #setIsLoading}), and the Action's title must be set.

Parameters
navigateAction Action

Returns
RoutePreviewNavigationTemplate.Builder

Throws
NullPointerException if navigateAction is null
IllegalArgumentException if navigateAction's title is null or empty

setTitle

public RoutePreviewNavigationTemplate.Builder setTitle (CharSequence title)

Sets the title of the template.

Unless set with this method, the template will not have a title.

Spans are not supported in the input string.

Parameters
title CharSequence

Returns
RoutePreviewNavigationTemplate.Builder

Throws
NullPointerException if title is null

See also: