PlaceListMapTemplate.Builder
public
static
final
class
PlaceListMapTemplate.Builder
extends Object
java.lang.Object | |
↳ | com.google.android.libraries.car.app.model.PlaceListMapTemplate.Builder |
A builder of PlaceListMapTemplate
.
Summary
Public constructors | |
---|---|
Builder()
|
Public methods | |
---|---|
PlaceListMapTemplate
|
build()
Constructs the template defined by this builder. |
PlaceListMapTemplate.Builder
|
setActionStrip(ActionStrip actionStrip)
Sets the |
PlaceListMapTemplate.Builder
|
setAnchor(Place anchor)
Sets the anchor maker on the map, or |
PlaceListMapTemplate.Builder
|
setCurrentLocationEnabled(boolean isEnabled)
Sets whether to show the current location in the map. |
PlaceListMapTemplate.Builder
|
setHeaderAction(Action headerAction)
Sets the |
PlaceListMapTemplate.Builder
|
setIsLoading(boolean isLoading)
Sets whether the template is in a loading state. |
PlaceListMapTemplate.Builder
|
setItemList(ItemList itemList)
Sets an |
PlaceListMapTemplate.Builder
|
setTitle(CharSequence title)
Sets the |
Inherited methods | |
---|---|
Public constructors
Builder
public Builder ()
Public methods
build
public PlaceListMapTemplate build ()
Constructs the template defined by this builder.
Requirements
Either a headerAction
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, or null
to not display an ActionStrip
.
Requirements
This template allows up to 2Action
s in its ActionStrip
. Of the 2 allowed
Action
s, one of them can contain a title as set via Action.Builder.setTitle(CharSequence)
.
Otherwise, only Action
s with icons are allowed.
Parameters | |
---|---|
actionStrip |
ActionStrip |
Returns | |
---|---|
PlaceListMapTemplate.Builder |
Throws | |
---|---|
IllegalArgumentException |
if actionStrip does not meet the template's
requirements.
|
setAnchor
public PlaceListMapTemplate.Builder setAnchor (Place anchor)
Sets the anchor maker on the map, or null
to not display an anchor marker.
The anchor marker is displayed differently from other markers by the host.
If not null
, an anchor marker will be shown at the specified LatLng
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 |
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, or null
to not display an action.
Requirements
This template only supports either either one ofAction.APP_ICON
and Action.BACK
as a header Action
.
Parameters | |
---|---|
headerAction |
Action |
Returns | |
---|---|
PlaceListMapTemplate.Builder |
Throws | |
---|---|
IllegalArgumentException |
if headerAction does not meet the template's
requirements.
|
setIsLoading
public PlaceListMapTemplate.Builder setIsLoading (boolean isLoading)
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 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 | |
---|---|
PlaceListMapTemplate.Builder |
setItemList
public PlaceListMapTemplate.Builder setItemList (ItemList itemList)
Sets an ItemList
to show in a 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 display the PlaceMarker
in both the map and the list view as the row becomes visible.
Requirements
This template allows up to 6Row
s 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. A row is
browsable when it's configured like so with Row.Builder.setIsBrowsable(boolean)
.
Parameters | |
---|---|
itemList |
ItemList |
Returns | |
---|---|
PlaceListMapTemplate.Builder |
Throws | |
---|---|
IllegalArgumentException |
if itemList does not meet the template's
requirements.
|
setTitle
public PlaceListMapTemplate.Builder setTitle (CharSequence title)
Sets the CharSequence
to show as the template's title, or null
to not display
a title.
Parameters | |
---|---|
title |
CharSequence |
Returns | |
---|---|
PlaceListMapTemplate.Builder |