public final class

SectionedItemTemplate.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.SectionedItemTemplate.Builder

Overview

A builder that constructs SectionedItemTemplate instances.

Upon building, this class validates the following:

  • The template is not both loading and populated with sections
  • Only RowSection and/or GridSection are added as sections

Summary

Constructors
publicBuilder()

Create a new SectionedItemTemplate builder.

publicBuilder(SectionedItemTemplate template)

Create a new SectionedItemTemplate builder, copying the values from an existing instance.

Methods
public SectionedItemTemplate.BuilderaddAction(Action action)

Adds a single Action to this template, appending to the existing list of actions.

public SectionedItemTemplate.BuilderaddSection(Section<Item> section)

Adds a single Section to this template, appending to the existing list of sections.

public SectionedItemTemplatebuild()

Constructs a new SectionedItemTemplate from the current state of this builder, throwing exceptions for any invalid state.

public SectionedItemTemplate.BuilderclearActions()

Removes all actions in this template.

public SectionedItemTemplate.BuilderclearSections()

Removes all sections from this template.

public SectionedItemTemplate.BuildersetActions(java.util.List<Action> actions)

Sets the actions that show up alongside the sections of this template (as opposed to the actions in the header), overwriting any other previously set actions from SectionedItemTemplate.Builder.addAction(Action) or SectionedItemTemplate.Builder.setActions(List).

public SectionedItemTemplate.BuildersetHeader(Header header)

Sets or clears the optional header for this template.

public SectionedItemTemplate.BuildersetLoading(boolean isLoading)

Sets whether or not this template is in a loading state.

public SectionedItemTemplate.BuildersetSections(java.util.List<Section> sections)

Sets the sections in this template, overwriting any other previously set sections.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Create a new SectionedItemTemplate builder.

public Builder(SectionedItemTemplate template)

Create a new SectionedItemTemplate builder, copying the values from an existing instance.

Methods

public SectionedItemTemplate.Builder setSections(java.util.List<Section> sections)

Sets the sections in this template, overwriting any other previously set sections. Only sections listed in SectionedItemTemplate.Builder can be added.

See also: for a list of allowed section types

public SectionedItemTemplate.Builder addSection(Section<Item> section)

Adds a single Section to this template, appending to the existing list of sections. Only sections listed in SectionedItemTemplate.Builder can be added.

See also: for a list of allowed section types

public SectionedItemTemplate.Builder clearSections()

Removes all sections from this template.

public SectionedItemTemplate.Builder setActions(java.util.List<Action> actions)

Sets the actions that show up alongside the sections of this template (as opposed to the actions in the header), overwriting any other previously set actions from SectionedItemTemplate.Builder.addAction(Action) or SectionedItemTemplate.Builder.setActions(List). All actions must conform to the ActionsConstraints.ACTIONS_CONSTRAINTS_FAB constraints.

public SectionedItemTemplate.Builder addAction(Action action)

Adds a single Action to this template, appending to the existing list of actions. All actions must conform to the ActionsConstraints.ACTIONS_CONSTRAINTS_FAB constraints.

public SectionedItemTemplate.Builder clearActions()

Removes all actions in this template.

public SectionedItemTemplate.Builder setHeader(Header header)

Sets or clears the optional header for this template.

public SectionedItemTemplate.Builder setLoading(boolean isLoading)

Sets whether or not this template is in a loading state. If passed true, sections cannot be added to the template.

public SectionedItemTemplate build()

Constructs a new SectionedItemTemplate from the current state of this builder, throwing exceptions for any invalid state.

See also: for the list of validation logic