Android 12 Developer Preview is here! Try it out, and give us your feedback!

PlaceListNavigationTemplate.Builder

public static final class PlaceListNavigationTemplate.Builder
extends Object

java.lang.Object
   ↳ com.google.android.libraries.car.app.navigation.model.PlaceListNavigationTemplate.Builder


A builder of PlaceListNavigationTemplate.

Summary

Public constructors

Builder()

Public methods

PlaceListNavigationTemplate build()

Constructs the template defined by this builder.

PlaceListNavigationTemplate.Builder setActionStrip(ActionStrip actionStrip)

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

PlaceListNavigationTemplate.Builder setHeaderAction(Action headerAction)

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

PlaceListNavigationTemplate.Builder setIsLoading(boolean isLoading)

Sets whether the template is in a loading state.

PlaceListNavigationTemplate.Builder setItemList(ItemList itemList)

Sets an ItemList to show in the list view along with the map, or null to not display a list.

PlaceListNavigationTemplate.Builder setTitle(CharSequence title)

Sets the CharSequence to show as title, or null to not show a title.

Inherited methods

Public constructors

Builder

public Builder ()

Public methods

build

public PlaceListNavigationTemplate build ()

Constructs the template defined by this builder.

Requirements

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

Returns
PlaceListNavigationTemplate

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

setActionStrip

public PlaceListNavigationTemplate.Builder setActionStrip (ActionStrip actionStrip)

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

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(CharSequence). Otherwise, only Actions with icons are allowed.

Parameters
actionStrip ActionStrip

Returns
PlaceListNavigationTemplate.Builder

Throws
IllegalArgumentException if actionStrip does not meet the template's requirements.

setHeaderAction

public PlaceListNavigationTemplate.Builder setHeaderAction (Action headerAction)

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

Requirements

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

Parameters
headerAction Action

Returns
PlaceListNavigationTemplate.Builder

Throws
IllegalArgumentException if headerAction does not meet the template's requirements.

setIsLoading

public PlaceListNavigationTemplate.Builder setIsLoading (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. If set to false, the UI shows the ItemList contents added via setItemList(ItemList).

Parameters
isLoading boolean

Returns
PlaceListNavigationTemplate.Builder

setItemList

public PlaceListNavigationTemplate.Builder setItemList (ItemList itemList)

Sets an ItemList to show in the list view along with the map, or null to not display a list.

To show a marker corresponding to a point of interest represented by a row, set the Place instance via Row.Builder.setMetadata(Metadata). The host will render the PlaceMarker in the list view as the row become visible. The app should synchronize with the list's behavior by rendering the same marker on the map surface.

Requirements

This template allows up to 6 Rows in the ItemList. The host will ignore any items over that limit. The list itself cannot be selectable as set via ItemList.Builder.setSelectable(ItemList.OnSelectedListener). Each Row can add up to 2 lines of texts via Row.Builder.addText(CharSequence) and cannot contain a Toggle.

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

Rows are not allowed to have both and an image and a place marker.

All non-browsable rows must have a DistanceSpan attached to either its title or texts, to indicate the distance of the point of interest from the current location. Where in the title or text the span is attached to is up to the app.

Parameters
itemList ItemList

Returns
PlaceListNavigationTemplate.Builder

Throws
IllegalArgumentException if itemList does not meet the template's requirements.

setTitle

public PlaceListNavigationTemplate.Builder setTitle (CharSequence title)

Sets the CharSequence to show as title, or null to not show a title.

Parameters
title CharSequence

Returns
PlaceListNavigationTemplate.Builder