ListTemplate.Builder
class ListTemplate.Builder
A builder of ListTemplate.
Summary
Public functions |
|
|---|---|
ListTemplate.Builder |
@RequiresCarApi(value = 6)Adds a template scoped action outside the rows. |
ListTemplate.Builder |
Adds an |
ListTemplate |
build()Constructs the template defined by this builder. |
ListTemplate.Builder |
Clears all of the |
ListTemplate.Builder |
This function is deprecated. Use |
ListTemplate.Builder |
@RequiresCarApi(value = 7)Sets the |
ListTemplate.Builder |
This function is deprecated. |
ListTemplate.Builder |
setLoading(isLoading: Boolean)Sets whether the template is in a loading state. |
ListTemplate.Builder |
setSingleList(list: ItemList)Sets a single |
ListTemplate.Builder |
This function is deprecated. Use |
Public functions
addAction
@RequiresCarApi(value = 6)
fun addAction(action: Action): ListTemplate.Builder
Adds a template scoped action outside the rows.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
ACTIONS_CONSTRAINTS_FAB |
addSectionedList
fun addSectionedList(list: SectionedItemList): ListTemplate.Builder
Adds an SectionedItemList to display in the template.
Use this method to add multiple lists to the template. Each SectionedItemList will be grouped under its header. These lists cannot be mixed with an ItemList added via setSingleList. If a single list was previously added, it will be cleared.
If the added SectionedItemList contains a ItemList.OnSelectedListener, then it cannot be added alongside other SectionedItemList(s).
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
build
fun build(): ListTemplate
Constructs the template defined by this builder.
Requirements The number of items in theItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_LIST. The host will ignore any items over that limit. Each Rows can add up to 2 lines of texts via addText.
If none of the header Action, the header title or the action strip have been set on the template, the header is hidden.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if the template is in a loading state but there are lists added or vice versa |
java.lang.IllegalArgumentException |
if the added |
| See also | |
|---|---|
getContentLimit |
clearSectionedLists
@ExperimentalCarApi
fun clearSectionedLists(): ListTemplate.Builder
Clears all of the SectionedItemLists added via addSectionedList
funsetActionStrip(actionStrip: ActionStrip): ListTemplate.Builder
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 2Actions in its ActionStrip. Of the 2 allowed Actions, one of them can contain a title as set via setTitle. Otherwise, only Actions with icons are allowed.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setHeader
@RequiresCarApi(value = 7)
fun setHeader(header: Header): ListTemplate.Builder
Sets the Header for this template.
The end header actions will show up differently inside vs outside of a map template. See addEndHeaderAction for more details.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
funsetHeaderAction(headerAction: Action): ListTemplate.Builder
Sets the Action that will be displayed in the header of the template, or null to not display an action.
Unless set with this method, the template will not have a header action.
Requirements This template only supports either one ofAPP_ICON and BACK as a header Action.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setLoading
fun setLoading(isLoading: Boolean): ListTemplate.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 will display the contents of the ItemList instance(s) added via setSingleList or addSectionedList.
setSingleList
fun setSingleList(list: ItemList): ListTemplate.Builder
Sets a single ItemList to show in the template.
Note that this list cannot be mixed with others added via addSectionedList . If multiple lists were previously added, they will be cleared.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
funsetTitle(title: CharSequence): ListTemplate.Builder
Sets the title of the template.
Unless set with this method, the template will not have a title.
Only DistanceSpans and DurationSpans are supported in the input string.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |