RoutePreviewNavigationTemplate.Builder
public
static
final
class
RoutePreviewNavigationTemplate.Builder
extends Object
java.lang.Object | |
↳ | com.google.android.libraries.car.app.navigation.model.RoutePreviewNavigationTemplate.Builder |
A builder of RoutePreviewNavigationTemplate
.
Summary
Public constructors | |
---|---|
Builder()
|
Public methods | |
---|---|
RoutePreviewNavigationTemplate
|
build()
Constructs the template defined by this builder. |
RoutePreviewNavigationTemplate.Builder
|
setActionStrip(ActionStrip actionStrip)
Sets the |
RoutePreviewNavigationTemplate.Builder
|
setHeaderAction(Action headerAction)
Sets the |
RoutePreviewNavigationTemplate.Builder
|
setIsLoading(boolean isLoading)
Sets whether the template is in a loading state. |
RoutePreviewNavigationTemplate.Builder
|
setItemList(ItemList itemList)
Sets an |
RoutePreviewNavigationTemplate.Builder
|
setNavigateAction(Action navigateAction)
Sets the |
RoutePreviewNavigationTemplate.Builder
|
setTitle(CharSequence title)
Sets the |
Inherited methods | |
---|---|
Public constructors
Builder
public Builder ()
Public methods
build
public RoutePreviewNavigationTemplate build ()
Constructs the template defined by this builder.
Requirements
Either a headerAction
or title must be set on the template.
Returns | |
---|---|
RoutePreviewNavigationTemplate |
Throws | |
---|---|
IllegalStateException |
if the template is in a loading state but the list is set, or vice-versa. |
IllegalStateException |
if the template is not loading and the navigation action is not set. |
IllegalStateException |
if the template does not have either a title or header Action set.
|
setActionStrip
public RoutePreviewNavigationTemplate.Builder setActionStrip (ActionStrip actionStrip)
Sets the ActionStrip
for this template, or null
to not show 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 | |
---|---|
RoutePreviewNavigationTemplate.Builder |
Throws | |
---|---|
IllegalArgumentException |
if actionStrip does not meet the template's
requirements.
|
setHeaderAction
public RoutePreviewNavigationTemplate.Builder setHeaderAction (Action headerAction)
Sets the Action
that will be displayed in the header of the template, or null
to now 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 | |
---|---|
RoutePreviewNavigationTemplate.Builder |
Throws | |
---|---|
IllegalArgumentException |
if headerAction does not meet the template's
requirements.
|
setIsLoading
public RoutePreviewNavigationTemplate.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 | |
---|---|
RoutePreviewNavigationTemplate.Builder |
setItemList
public RoutePreviewNavigationTemplate.Builder setItemList (ItemList itemList)
Sets an ItemList
to show route options in a list view along with the map.
Requirements
This template allows up to 3Row
s in the ItemList
. The host will ignore any
items over that limit. The list must have an OnClickListener
set. 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.
All rows must have either a DistanceSpan
or a DurationSpan
attached to either its title or
texts, to indicate an estimate trip distance or duration for the route it represents. Where
in the title or text these spans are attached to is up to the app.
Parameters | |
---|---|
itemList |
ItemList |
Returns | |
---|---|
RoutePreviewNavigationTemplate.Builder |
Throws | |
---|---|
IllegalArgumentException |
if itemList does not meet the template's
requirements.
|
setNavigateAction
public RoutePreviewNavigationTemplate.Builder setNavigateAction (Action navigateAction)
Sets the Action
to allow users to request navigation using the currently selected
route.
This should not be null
if the template is not in a loading state (see
#setIsLoading}), and the Action
's title must be set.
Parameters | |
---|---|
navigateAction |
Action |
Returns | |
---|---|
RoutePreviewNavigationTemplate.Builder |
Throws | |
---|---|
NullPointerException |
if navigateAction is null . |
IllegalArgumentException |
if navigateAction 's title is null or empty.
|
setTitle
public RoutePreviewNavigationTemplate.Builder setTitle (CharSequence title)
Sets the CharSequence
to show as title, or null
to not show a title.
Parameters | |
---|---|
title |
CharSequence |
Returns | |
---|---|
RoutePreviewNavigationTemplate.Builder |