RoutePreviewNavigationTemplate.Builder

Added in 1.0.0
Deprecated in 1.7.0-beta03

class RoutePreviewNavigationTemplate.Builder


A builder of RoutePreviewNavigationTemplate.

Summary

Public constructors

Constructs an empty Builder instance.

Public functions

RoutePreviewNavigationTemplate

Constructs the template defined by this builder.

RoutePreviewNavigationTemplate.Builder

Sets the ActionStrip for this template.

RoutePreviewNavigationTemplate.Builder
@RequiresCarApi(value = 5)
setHeader(header: Header)

Sets the Header for this template.

RoutePreviewNavigationTemplate.Builder
setHeaderAction(headerAction: Action)

This function is deprecated.

use setHeader

RoutePreviewNavigationTemplate.Builder
setItemList(itemList: ItemList)

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

RoutePreviewNavigationTemplate.Builder
setLoading(isLoading: Boolean)

Sets whether the template is in a loading state.

RoutePreviewNavigationTemplate.Builder
@RequiresCarApi(value = 4)
setMapActionStrip(actionStrip: ActionStrip)

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

RoutePreviewNavigationTemplate.Builder
setNavigateAction(navigateAction: Action)

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

RoutePreviewNavigationTemplate.Builder
@RequiresCarApi(value = 4)
setPanModeListener(panModeListener: PanModeListener)

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

RoutePreviewNavigationTemplate.Builder
setTitle(title: CarText)

This function is deprecated.

use setHeader

RoutePreviewNavigationTemplate.Builder

This function is deprecated.

use setHeader

Public constructors

Builder

Added in 1.0.0
Deprecated in 1.7.0-beta03
Builder()

Constructs an empty Builder instance.

Public functions

build

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun build(): RoutePreviewNavigationTemplate

Constructs the template defined by this builder.

Requirements

If neither header Action nor title have been set on the template, the header is hidden.

Throws
java.lang.IllegalStateException

if the template is in a loading state but the list is set or vice versa, or if the template is not loading and the navigation action is not set.

setActionStrip

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun setActionStrip(actionStrip: ActionStrip): RoutePreviewNavigationTemplate.Builder

Sets the ActionStrip for this template.

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

The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.

Requirements This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
Throws
java.lang.IllegalArgumentException

if actionStrip does not meet the requirements

java.lang.NullPointerException

if actionStrip is null

setHeader

Added in 1.3.0
Deprecated in 1.7.0-beta03
@RequiresCarApi(value = 5)
fun setHeader(header: Header): RoutePreviewNavigationTemplate.Builder

Sets the Header for this template.

Throws
java.lang.NullPointerException

if header is null

setHeaderAction

Added in 1.0.0
Deprecated in 1.3.0
fun setHeaderAction(headerAction: Action): RoutePreviewNavigationTemplate.Builder

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 APP_ICON and BACK as a header Action.
Throws
java.lang.IllegalArgumentException

if headerAction does not meet the template's requirements

java.lang.NullPointerException

if headerAction is null

setItemList

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun setItemList(itemList: ItemList): RoutePreviewNavigationTemplate.Builder

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

Requirements The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_ROUTE_LIST. 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 addText and cannot contain a Toggle.

Images of type IMAGE_TYPE_LARGE are not allowed in this template.

All rows must have either a androidx.car.app.model.DistanceSpan or a 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.

Throws
java.lang.IllegalArgumentException

if itemList does not meet the template's requirements

java.lang.NullPointerException

if itemList is null

See also
getContentLimit

setLoading

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun setLoading(isLoading: Boolean): RoutePreviewNavigationTemplate.Builder

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 invalidate and send the new template content to the host once the data is ready.

setMapActionStrip

Added in 1.1.0
Deprecated in 1.7.0-beta03
@RequiresCarApi(value = 4)
fun setMapActionStrip(actionStrip: ActionStrip): RoutePreviewNavigationTemplate.Builder

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.

If the app does not include the PAN button in this ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.

Requirements This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via setIcon are allowed.
Throws
java.lang.IllegalArgumentException

if actionStrip does not meet the template's requirements

java.lang.NullPointerException

if actionStrip is null

setNavigateAction

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun setNavigateAction(navigateAction: Action): RoutePreviewNavigationTemplate.Builder

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.

Spans are not supported in the navigate action and will be ignored.

Throws
java.lang.NullPointerException

if navigateAction is null

java.lang.IllegalArgumentException

if navigateAction's title is null or empty

setPanModeListener

Added in 1.1.0
Deprecated in 1.7.0-beta03
@RequiresCarApi(value = 4)
fun setPanModeListener(panModeListener: PanModeListener): RoutePreviewNavigationTemplate.Builder

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

If the app does not include the PAN button in the map ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.

Throws
java.lang.NullPointerException

if panModeListener is null

setTitle

Added in 1.1.0
Deprecated in 1.3.0
fun setTitle(title: CarText): RoutePreviewNavigationTemplate.Builder

Sets the title of the template, with support for multiple length variants.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText

setTitle

Added in 1.0.0
Deprecated in 1.3.0
fun setTitle(title: CharSequence): RoutePreviewNavigationTemplate.Builder

Sets the title of the template.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText