PlaceListNavigationTemplate.Builder

public static final class PlaceListNavigationTemplate.Builder
extends Object

java.lang.Object
   ↳ androidx.car.app.navigation.model.PlaceListNavigationTemplate.Builder


A builder of PlaceListNavigationTemplate.

Summary

Public constructors

Builder()

Constructs an empty PlaceListNavigationTemplate.Builder instance.

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 display an ActionStrip.

PlaceListNavigationTemplate.Builder setHeaderAction(Action headerAction)

Sets the Action that will be displayed in the header of the template.

PlaceListNavigationTemplate.Builder setItemList(ItemList itemList)

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

PlaceListNavigationTemplate.Builder setLoading(boolean isLoading)

Sets whether the template is in a loading state.

PlaceListNavigationTemplate.Builder setTitle(CharSequence title)

Sets the title of the template.

PlaceListNavigationTemplate.Builder setTitle(CarText title)

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

Inherited methods

Public constructors

Builder

public Builder ()

Constructs an empty PlaceListNavigationTemplate.Builder instance.

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 display an ActionStrip.

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

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

Parameters
actionStrip ActionStrip

Returns
PlaceListNavigationTemplate.Builder

Throws
IllegalArgumentException if actionStrip does not meet the requirements
NullPointerException if actionStrip is null

setHeaderAction

public PlaceListNavigationTemplate.Builder setHeaderAction (Action headerAction)

Sets the Action that will be displayed in the header of the template.

Unless set with this method, the template will not have a header action.

Requirements

This template only supports 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
NullPointerException if headerAction is null

setItemList

public PlaceListNavigationTemplate.Builder setItemList (ItemList itemList)

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

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

The number of items in the ItemList should be smaller or equal than the limit provided by ConstraintManager.CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via ItemList.Builder.setOnSelectedListener(ItemList.OnSelectedListener). Each Row can add up to 2 lines of texts via Row.Builder.addText(CarText) 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
NullPointerException if itemList is null

setLoading

public PlaceListNavigationTemplate.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 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

setTitle

public PlaceListNavigationTemplate.Builder setTitle (CharSequence title)

Sets the title of the template.

Only DistanceSpans and DurationSpans are supported in the input string.

Parameters
title CharSequence

Returns
PlaceListNavigationTemplate.Builder

Throws
NullPointerException if title is null
IllegalArgumentException if title contains unsupported spans

See also:

setTitle

public PlaceListNavigationTemplate.Builder setTitle (CarText title)

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

Only DistanceSpans and DurationSpans are supported in the input string.

Parameters
title CarText

Returns
PlaceListNavigationTemplate.Builder

Throws
NullPointerException if title is null
IllegalArgumentException if title contains unsupported spans

See also: