PlaceListMapTemplate.Builder

public static final class PlaceListMapTemplate.Builder
extends Object

java.lang.Object
   ↳ androidx.car.app.model.PlaceListMapTemplate.Builder


A builder of PlaceListMapTemplate.

Summary

Public constructors

Builder()

Returns an empty PlaceListMapTemplate.Builder instance.

Public methods

PlaceListMapTemplate build()

Constructs the template defined by this builder.

PlaceListMapTemplate.Builder setActionStrip(ActionStrip actionStrip)

Sets the ActionStrip for this template.

PlaceListMapTemplate.Builder setAnchor(Place anchor)

Sets the anchor maker on the map.

PlaceListMapTemplate.Builder setCurrentLocationEnabled(boolean isEnabled)

Sets whether to show the current location in the map.

PlaceListMapTemplate.Builder setHeaderAction(Action headerAction)

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

PlaceListMapTemplate.Builder setItemList(ItemList itemList)

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

PlaceListMapTemplate.Builder setLoading(boolean isLoading)

Sets whether the template is in a loading state.

PlaceListMapTemplate.Builder setTitle(CharSequence title)

Sets the title of the template.

PlaceListMapTemplate.Builder setTitle(CarText title)

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

Inherited methods

Public constructors

Builder

public Builder ()

Returns an empty PlaceListMapTemplate.Builder instance.

Public methods

build

public PlaceListMapTemplate build ()

Constructs the template defined by this builder.

Requirements

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

Returns
PlaceListMapTemplate

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 PlaceListMapTemplate.Builder setActionStrip (ActionStrip actionStrip)

Sets the ActionStrip for this template.

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
PlaceListMapTemplate.Builder

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

setAnchor

public PlaceListMapTemplate.Builder setAnchor (Place anchor)

Sets the anchor maker on the map.

An anchor marker will not be displayed unless set with this method.

The anchor marker is displayed differently from other markers by the host.

If not null, an anchor marker will be shown at the specified CarLocation on the map. The camera will adapt to always have the anchor marker visible within its viewport, along with other places' markers from Row that are currently visible in the Pane. This can be used to provide a reference point on the map (e.g. the center of a search region) as the user pages through the Pane's markers, for example.

Parameters
anchor Place

Returns
PlaceListMapTemplate.Builder

Throws
NullPointerException if anchor is null

setCurrentLocationEnabled

public PlaceListMapTemplate.Builder setCurrentLocationEnabled (boolean isEnabled)

Sets whether to show the current location in the map.

The map template will show the user's current location on the map, which is normally indicated by a blue dot.

This functionality requires the app to have the ACCESS_FINE_LOCATION permission.

Parameters
isEnabled boolean

Returns
PlaceListMapTemplate.Builder

setHeaderAction

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