RoutePreviewNavigationTemplate.Builder

Added in 1.0.0
Deprecated in 1.7.0-beta02

public final class RoutePreviewNavigationTemplate.Builder


A builder of RoutePreviewNavigationTemplate.

Summary

Public constructors

Constructs an empty Builder instance.

Public methods

@NonNull RoutePreviewNavigationTemplate

Constructs the template defined by this builder.

@NonNull RoutePreviewNavigationTemplate.Builder

Sets the ActionStrip for this template.

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

Sets the Header for this template.

@NonNull RoutePreviewNavigationTemplate.Builder

This method is deprecated.

use setHeader

@NonNull RoutePreviewNavigationTemplate.Builder

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

@NonNull RoutePreviewNavigationTemplate.Builder
setLoading(boolean isLoading)

Sets whether the template is in a loading state.

@NonNull RoutePreviewNavigationTemplate.Builder

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

@NonNull RoutePreviewNavigationTemplate.Builder
setNavigateAction(@NonNull Action navigateAction)

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

@NonNull RoutePreviewNavigationTemplate.Builder

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

@NonNull RoutePreviewNavigationTemplate.Builder

This method is deprecated.

use setHeader

@NonNull RoutePreviewNavigationTemplate.Builder

This method is deprecated.

use setHeader

Public constructors

Builder

Added in 1.0.0
Deprecated in 1.7.0-beta02
public Builder()

Constructs an empty Builder instance.

Public methods

build

Added in 1.0.0
Deprecated in 1.7.0-beta02
public @NonNull RoutePreviewNavigationTemplate build()

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-beta02
public @NonNull RoutePreviewNavigationTemplate.Builder setActionStrip(@NonNull ActionStrip actionStrip)

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-beta02
@RequiresCarApi(value = 5)
public @NonNull RoutePreviewNavigationTemplate.Builder setHeader(@NonNull Header header)

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
public @NonNull RoutePreviewNavigationTemplate.Builder setHeaderAction(@NonNull 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 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-beta02
public @NonNull RoutePreviewNavigationTemplate.Builder setItemList(@NonNull ItemList itemList)

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-beta02
public @NonNull 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 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-beta02
@RequiresCarApi(value = 4)
public @NonNull RoutePreviewNavigationTemplate.Builder setMapActionStrip(@NonNull 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.

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-beta02
public @NonNull RoutePreviewNavigationTemplate.Builder setNavigateAction(@NonNull 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.

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-beta02
@RequiresCarApi(value = 4)
public @NonNull RoutePreviewNavigationTemplate.Builder setPanModeListener(@NonNull PanModeListener panModeListener)

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
public @NonNull RoutePreviewNavigationTemplate.Builder setTitle(@NonNull CarText title)

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
public @NonNull RoutePreviewNavigationTemplate.Builder setTitle(@NonNull CharSequence title)

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