SectionHeader.Builder


public final class SectionHeader.Builder


A builder of SectionHeader.

Summary

Public constructors

Returns a Builder instance configured with the given title.

Returns a Builder instance configured with the given title.

Public methods

@NonNull SectionHeader

Builds the SectionHeader.

@NonNull SectionHeader.Builder

Sets the end icon of the header.

@NonNull SectionHeader.Builder

Sets the headline of the header.

@NonNull SectionHeader.Builder

Sets the headline of the header.

@NonNull SectionHeader.Builder

Sets the click listener for the header.

@NonNull SectionHeader.Builder

Sets the start icon of the header with a default size of IMAGE_TYPE_SMALL.

@NonNull SectionHeader.Builder
@CanIgnoreReturnValue
setStartIcon(@NonNull CarIcon startIcon, int startIconType)

Sets the start icon of the header and its size type.

@NonNull SectionHeader.Builder

Sets the subtitle of the header.

@NonNull SectionHeader.Builder

Sets the subtitle of the header.

Public constructors

Builder

Added in 1.9.0-alpha03
public Builder(@NonNull CarText title)

Returns a Builder instance configured with the given title.

The title must be a plain string with no spans other than those supported by TEXT_ONLY.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

Builder

Added in 1.9.0-alpha03
public Builder(@NonNull CharSequence title)

Returns a Builder instance configured with the given title.

The title must be a plain string with no spans other than those supported by TEXT_ONLY.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText

Public methods

build

Added in 1.9.0-alpha03
public @NonNull SectionHeader build()

Builds the SectionHeader.

Throws
java.lang.IllegalStateException

if both headline and subtitle are set

setEndIcon

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setEndIcon(@NonNull CarIcon endIcon)

Sets the end icon of the header.

Only custom icon types (e.g. TYPE_CUSTOM) are supported.

Parameters
@NonNull CarIcon endIcon

the CarIcon to display after the title

Throws
java.lang.NullPointerException

if endIcon is null

java.lang.IllegalArgumentException

if endIcon is not a custom icon, or if it does not meet the UNCONSTRAINED constraints

setHeadline

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setHeadline(@Nullable CarText headline)

Sets the headline of the header.

The headline appears above the title as an eyebrow or overline. It must be a plain string with no spans other than those supported by TEXT_ONLY.

A section header cannot have both a headline and a subtitle. If both are set, build will throw an IllegalStateException.

Parameters
@Nullable CarText headline

the headline to set

Throws
java.lang.IllegalArgumentException

if headline contains unsupported spans

See also
CarText

setHeadline

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setHeadline(@NonNull CharSequence headline)

Sets the headline of the header.

The headline appears above the title as an eyebrow or overline. It must be a plain string with no spans other than those supported by TEXT_ONLY.

A section header cannot have both a headline and a subtitle. If both are set, build will throw an IllegalStateException.

Parameters
@NonNull CharSequence headline

the headline to set

Throws
java.lang.NullPointerException

if headline is null

java.lang.IllegalArgumentException

if headline contains unsupported spans

See also
CarText

setOnClickListener

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setOnClickListener(@NonNull OnClickListener onClickListener)

Sets the click listener for the header.

If a listener is set, the header will become focusable and clickable.

Throws
java.lang.NullPointerException

if onClickListener is null

setStartIcon

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setStartIcon(@NonNull CarIcon startIcon)

Sets the start icon of the header with a default size of IMAGE_TYPE_SMALL.

Only custom icon types (e.g. TYPE_CUSTOM) are supported.

Parameters
@NonNull CarIcon startIcon

the CarIcon to display before the title

Throws
java.lang.NullPointerException

if startIcon is null

java.lang.IllegalArgumentException

if startIcon is not a custom icon, or if it does not meet the UNCONSTRAINED constraints

setStartIcon

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setStartIcon(@NonNull CarIcon startIcon, int startIconType)

Sets the start icon of the header and its size type.

Only custom icon types (e.g. TYPE_CUSTOM) are supported.

Parameters
@NonNull CarIcon startIcon

the CarIcon to display before the title

int startIconType

the type of image to display. See SectionHeader for supported image types (e.g. IMAGE_TYPE_SMALL).

Throws
java.lang.NullPointerException

if startIcon is null

java.lang.IllegalArgumentException

if startIcon is not a custom icon, or if it does not meet the UNCONSTRAINED constraints

setSubtitle

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setSubtitle(@Nullable CarText subtitle)

Sets the subtitle of the header.

The subtitle appears below the title. It must be a plain string with no spans other than those supported by TEXT_WITH_COLORS.

A section header cannot have both a headline and a subtitle. If both are set, build will throw an IllegalStateException.

Parameters
@Nullable CarText subtitle

the subtitle to set

Throws
java.lang.IllegalArgumentException

if subtitle contains unsupported spans

See also
CarText

setSubtitle

Added in 1.9.0-alpha03
@CanIgnoreReturnValue
public @NonNull SectionHeader.Builder setSubtitle(@Nullable CharSequence subtitle)

Sets the subtitle of the header.

The subtitle appears below the title. It must be a plain string with no spans other than those supported by TEXT_WITH_COLORS.

A section header cannot have both a headline and a subtitle. If both are set, build will throw an IllegalStateException.

Parameters
@Nullable CharSequence subtitle

the subtitle to set

Throws
java.lang.IllegalArgumentException

if subtitle contains unsupported spans

See also
CarText