RoutePreviewNavigationTemplate

Added in 1.0.0
Deprecated in 1.7.0-beta02

@CarProtocol
public final class RoutePreviewNavigationTemplate implements Template


A template that supports showing a list of routes alongside a custom drawn map.

The list must have its ItemList.OnSelectedListener set, and the template must have its navigate action set (see setNavigateAction). These are used in conjunction to inform the app that:

  1. A route has been selected. The app should also highlight the route on the map surface.
  2. A navigate action has been triggered. The app should begin navigation using the selected route.

The template itself does not expose a drawing surface. In order to draw on the canvas, use setSurfaceCallback.

Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
  • The previous template is in a loading state (see setLoading, or
  • The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.

Note that specifically, this means the app should not use this template to continuously refresh the routes as the car moves.

In order to use this template your car app MUST declare that it uses the androidx.car.app.NAVIGATION_TEMPLATES permission in the manifest.

For instance, using the deprecated RoutePreviewNavigationTemplate, if the template was:
RoutePreviewNavigationTemplate template = new RoutePreviewNavigationTemplate
 .Builder()
         .setItemList(new ItemList.Builder()
                 .addItem(new Row.Builder()
                     .setTitle(title))
                     .build())
                 .build())
         .setHeader(header)
         .setNavigateAction(new Action.Builder()
                 .setTitle("drive")
                 .setOnClickListener(() -> {})
                 .build())
         .setActionStrip(actionStrip)
         .setMapActionStrip(mapActionStrip)
         .build();
The Navigate Action in RoutePreview is added as a secondary action for each row. Using the new MapWithContentTemplate, the template would be:
MapWithContentTemplate template = new MapWithContentTemplate.Builder()
             .setContentTemplate(new ListTemplate.Builder()
                    .setSingleList(new ItemList.Builder()
                         .addItem(new Row.Builder()
                              .setTitle(title))
                              .addAction(new Action.Builder()
                                     .setTitle("drive")
                                     .setOnClickListener(() -> {})
                                     .build())
                              .build())
                         .build()))
                    .setHeader(header)
                    .build())
             .setActionStrip(actionStrip)
             .setMapController(new MapController.Builder()
                   .setMapActionStrip(mapActionStrip)
                   .build())
             .build();
@deprecated with API 7. Use the MapWithContentTemplate API instead.

Summary

Nested types

A builder of RoutePreviewNavigationTemplate.

Public methods

boolean
@Nullable ActionStrip

Returns the ActionStrip for this template or null if not set.

@Nullable Header
@RequiresCarApi(value = 5)
getHeader()

Returns the Header to display in this template.

@Nullable Action

This method is deprecated.

use getHeader

@Nullable ItemList

Returns the ItemList to show route options in a list view along with the map or null if not set.

@Nullable ActionStrip

Returns the map ActionStrip for this template or null if not set.

@Nullable Action

Returns the Action to allow users to request navigation using the currently selected route or null if not set.

@Nullable PanModeDelegate

Returns the PanModeDelegate that should be called when the user interacts with pan mode on this template, or null if a PanModeListener was not set.

@Nullable CarText

This method is deprecated.

use getHeader

int
boolean

Returns whether the template is loading.

@NonNull String

Public methods

equals

public boolean equals(@Nullable Object other)

getActionStrip

Added in 1.0.0
Deprecated in 1.7.0-beta02
public @Nullable ActionStrip getActionStrip()

Returns the ActionStrip for this template or null if not set.

See also
setActionStrip

getHeader

Added in 1.3.0
Deprecated in 1.7.0-beta02
@RequiresCarApi(value = 5)
public @Nullable Header getHeader()

Returns the Header to display in this template.

See also
setHeader

getHeaderAction

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Action getHeaderAction()

Returns the Action that is set to be displayed in the header of the template or null if not set.

See also
setHeaderAction

getItemList

Added in 1.0.0
Deprecated in 1.7.0-beta02
public @Nullable ItemList getItemList()

Returns the ItemList to show route options in a list view along with the map or null if not set.

See also
setItemList

getMapActionStrip

Added in 1.1.0
Deprecated in 1.7.0-beta02
@RequiresCarApi(value = 4)
public @Nullable ActionStrip getMapActionStrip()

Returns the map ActionStrip for this template or null if not set.

getNavigateAction

Added in 1.0.0
Deprecated in 1.7.0-beta02
public @Nullable Action getNavigateAction()

Returns the Action to allow users to request navigation using the currently selected route or null if not set.

getPanModeDelegate

Added in 1.1.0
Deprecated in 1.7.0-beta02
@RequiresCarApi(value = 4)
public @Nullable PanModeDelegate getPanModeDelegate()

Returns the PanModeDelegate that should be called when the user interacts with pan mode on this template, or null if a PanModeListener was not set.

getTitle

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable CarText getTitle()

Returns the title of the template or null if not set.

See also
setTitle

hashCode

public int hashCode()

isLoading

Added in 1.0.0
Deprecated in 1.7.0-beta02
public boolean isLoading()

Returns whether the template is loading.

See also
setLoading

toString

public @NonNull String toString()