SectionedItemTemplate.Builder


@ExperimentalCarApi
class SectionedItemTemplate.Builder


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

Public constructors

Create a new SectionedItemTemplate builder.

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

Public functions

SectionedItemTemplate.Builder

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

SectionedItemTemplate.Builder

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

SectionedItemTemplate

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

SectionedItemTemplate.Builder

Removes all actions in this template.

SectionedItemTemplate.Builder

Removes all sections from this template.

SectionedItemTemplate.Builder

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 addAction or setActions.

SectionedItemTemplate.Builder

Sets whether this list can be indexed alphabetically, by item title.

SectionedItemTemplate.Builder

Sets or clears the optional header for this template.

SectionedItemTemplate.Builder

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

SectionedItemTemplate.Builder

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

Public constructors

Builder

Added in 1.7.0-beta03
Builder()

Create a new SectionedItemTemplate builder.

Builder

Added in 1.7.0-beta03
Builder(template: SectionedItemTemplate)

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

Public functions

addAction

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun addAction(action: Action): SectionedItemTemplate.Builder

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

addSection

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun addSection(section: Section<Any!>): SectionedItemTemplate.Builder

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

See also
SectionedItemTemplate.Builder

for a list of allowed section types

build

Added in 1.7.0-beta03
fun build(): SectionedItemTemplate

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

See also
SectionedItemTemplate.Builder

for the list of validation logic

clearActions

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun clearActions(): SectionedItemTemplate.Builder

Removes all actions in this template.

clearSections

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun clearSections(): SectionedItemTemplate.Builder

Removes all sections from this template.

setActions

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun setActions(actions: (Mutable)List<Action!>): SectionedItemTemplate.Builder

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 addAction or setActions. All actions must conform to the ACTIONS_CONSTRAINTS_FAB constraints.

setAlphabeticalIndexingAllowed

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun setAlphabeticalIndexingAllowed(alphabeticalIndexingAllowed: Boolean): SectionedItemTemplate.Builder

Sets whether this list can be indexed alphabetically, by item title. By default, this is false.

"Indexing" refers to the process of examining list contents (e.g. item titles) to sort, partition, or filter a list. Indexing is generally used for features called "Accelerators", which allow a user to quickly find a particular Item in a long list.

For example, a media app may, by default, show a user's playlists sorted by date created. If the app provides these playlists via the SectionedItemTemplate and enables isAlphabeticalIndexingAllowed, the user will be able to jump to their playlists that start with the letter "H". When this happens, the list is reconstructed and sorted alphabetically, then shown to the user, jumping down to the letter "H".

Individual items may be excluded from the list by setting their #isIndexable field to false.

setHeader

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun setHeader(header: Header?): SectionedItemTemplate.Builder

Sets or clears the optional header for this template.

setLoading

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun setLoading(isLoading: Boolean): SectionedItemTemplate.Builder

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

setSections

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun setSections(sections: (Mutable)List<Section<Any!>!>): SectionedItemTemplate.Builder

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

See also
SectionedItemTemplate.Builder

for a list of allowed section types