RoutePreviewNavigationTemplate

Added in 1.0.0
Deprecated in 1.7.0-beta03

@CarProtocol
class RoutePreviewNavigationTemplate : 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

Public functions

Boolean
equals(other: Any?)
ActionStrip?

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

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

Returns the Header to display in this template.

Action?

This function is deprecated.

use getHeader

ItemList?

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

ActionStrip?

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

Action?

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

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.

CarText?

This function is deprecated.

use getHeader

Int
Boolean

Returns whether the template is loading.

String

Public functions

equals

fun equals(other: Any?): Boolean

getActionStrip

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun getActionStrip(): ActionStrip?

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-beta03
@RequiresCarApi(value = 5)
fun getHeader(): Header?

Returns the Header to display in this template.

See also
setHeader

getHeaderAction

Added in 1.0.0
Deprecated in 1.3.0
fun getHeaderAction(): Action?

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-beta03
fun getItemList(): ItemList?

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-beta03
@RequiresCarApi(value = 4)
fun getMapActionStrip(): ActionStrip?

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

getNavigateAction

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun getNavigateAction(): Action?

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-beta03
@RequiresCarApi(value = 4)
fun getPanModeDelegate(): 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.

getTitle

Added in 1.0.0
Deprecated in 1.3.0
fun getTitle(): CarText?

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

See also
setTitle

hashCode

fun hashCode(): Int

isLoading

Added in 1.0.0
Deprecated in 1.7.0-beta03
fun isLoading(): Boolean

Returns whether the template is loading.

See also
setLoading

toString

fun toString(): String