PlaceListMapTemplate.Builder


class PlaceListMapTemplate.Builder


A builder of PlaceListMapTemplate.

Summary

Public constructors

Returns an empty Builder instance.

Public functions

PlaceListMapTemplate

Constructs the template defined by this builder.

PlaceListMapTemplate.Builder

Sets the ActionStrip for this template.

PlaceListMapTemplate.Builder
setAnchor(anchor: Place)

Sets the anchor maker on the map.

PlaceListMapTemplate.Builder

Sets whether to show the current location in the map.

PlaceListMapTemplate.Builder
setHeaderAction(headerAction: Action)

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(isLoading: Boolean)

Sets whether the template is in a loading state.

PlaceListMapTemplate.Builder
@RequiresCarApi(value = 5)
setOnContentRefreshListener(
    onContentRefreshListener: OnContentRefreshListener
)

Sets the OnContentRefreshListener to call when the user requests for the list contents to be refreshed in this template.

PlaceListMapTemplate.Builder
setTitle(title: CarText)

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

PlaceListMapTemplate.Builder

Sets the title of the template.

Public constructors

Builder

Added in 1.0.0
Builder()

Returns an empty Builder instance.

Public functions

build

Added in 1.0.0
fun build(): PlaceListMapTemplate

Constructs the template defined by this builder.

Requirements

If neither header Action nor title have been set on the template, the header is hidden.

Throws
java.lang.IllegalArgumentException

if the template is in a loading state but the list is set, or vice versa

setActionStrip

Added in 1.0.0
fun setActionStrip(actionStrip: ActionStrip): PlaceListMapTemplate.Builder

Sets the ActionStrip for this template.

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

The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.

Requirements This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
Throws
java.lang.IllegalArgumentException

if actionStrip does not meet the requirements

java.lang.NullPointerException

if actionStrip is null

setAnchor

Added in 1.0.0
fun setAnchor(anchor: Place): PlaceListMapTemplate.Builder

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.

Throws
java.lang.NullPointerException

if anchor is null

setCurrentLocationEnabled

Added in 1.0.0
fun setCurrentLocationEnabled(isEnabled: Boolean): PlaceListMapTemplate.Builder

Sets whether to show the current location in the map.

The map template will show the user's current location on the map.

This functionality requires the app to have either the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission. When isEnabled is true, the host may receive location updates from the app in order to show the user's current location.

setHeaderAction

Added in 1.0.0
fun setHeaderAction(headerAction: Action): PlaceListMapTemplate.Builder

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 APP_ICON and BACK as a header Action.
Throws
java.lang.IllegalArgumentException

if headerAction does not meet the template's requirements

java.lang.NullPointerException

if headerAction is null

setItemList

Added in 1.0.0
fun setItemList(itemList: ItemList): PlaceListMapTemplate.Builder

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

Unless set with this method, the template will not show an item list.

To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.

Requirements The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.

Images of type 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. A row is browsable when it's configured like so with setBrowsable.

Throws
java.lang.IllegalArgumentException

if itemList does not meet the template's requirements

java.lang.NullPointerException

if itemList is null

See also
getContentLimit

setLoading

Added in 1.0.0
fun setLoading(isLoading: Boolean): PlaceListMapTemplate.Builder

Sets whether the template is in a loading state.

If set to true, the UI will display a loading indicator where the list content would be otherwise. The caller is expected to call invalidate and send the new template content to the host once the data is ready. If set to false, the UI shows the contents added via setItemList.

setOnContentRefreshListener

Added in 1.2.0
@RequiresCarApi(value = 5)
fun setOnContentRefreshListener(
    onContentRefreshListener: OnContentRefreshListener
): PlaceListMapTemplate.Builder

Sets the OnContentRefreshListener to call when the user requests for the list contents to be refreshed in this template.

When the listener is triggered, an app can send a new PlaceListMapTemplate, for example, to show a new set of point-of-interests based on the current user location, without the car host counting it against the template quota described in onGetTemplate.

Throws
java.lang.NullPointerException

if itemVisibilityChangedListener is null

setTitle

Added in 1.1.0
fun setTitle(title: CarText): PlaceListMapTemplate.Builder

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

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText

setTitle

Added in 1.0.0
fun setTitle(title: CharSequence): PlaceListMapTemplate.Builder

Sets the title of the template.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText