Banner.Builder


class Banner.Builder


A builder of Banner.

Summary

Public constructors

Returns an empty Builder instance.

Public functions

Banner.Builder

Adds an Action below the title and subtitle of the Banner.

Banner.Builder

Adds an Action to the trailing part of the banner.

Banner.Builder

Adds a CarIcon to be displayed as an icon to the trailing part of the banner.

Banner.Builder

Adds a CarIcon to be displayed as an image to the trailing part of the banner.

Banner

Constructs the Banner defined by this builder.

Banner.Builder

Sets the Background of the banner.

Banner.Builder

Sets the leading element in this banner to be a CarIcon displayed as an icon.

Banner.Builder

Sets the leading element in this banner to be a CarIcon displayed as an image.

Banner.Builder

Sets the OnClickListener to be called back when the banner is clicked.

Banner.Builder
setSubtitle(subtitle: CarText)

Sets the subtitle of the banner.

Banner.Builder

Sets the subtitle of the banner.

Banner.Builder
setTitle(title: CarText)

Sets the title of the banner.

Banner.Builder

Sets the title of the banner.

Public constructors

Builder

Added in 1.8.0
Builder()

Returns an empty Builder instance.

Public functions

addBelowAction

Added in 1.8.0
fun addBelowAction(action: Action): Banner.Builder

Adds an Action below the title and subtitle of the Banner.

A Banner's below actions must conform to ACTION_CONSTRAINTS_BANNER_BELOW

addTrailingAction

Added in 1.8.0
fun addTrailingAction(action: Action): Banner.Builder

Adds an Action to the trailing part of the banner.

A banner can have at most 2 trailing elements

action must conform to ACTION_CONSTRAINTS_BANNER_TRAILING.

Throws
java.lang.NullPointerException

if action is null

java.lang.IllegalArgumentException

if there are already 2 trailing elements

addTrailingIcon

Added in 1.8.0
fun addTrailingIcon(icon: CarIcon): Banner.Builder

Adds a CarIcon to be displayed as an icon to the trailing part of the banner.

A banner can have at most 2 trailing elements

Throws
java.lang.NullPointerException

if icon is null

java.lang.IllegalArgumentException

if there are already 2 trailing elements

addTrailingImage

Added in 1.8.0
fun addTrailingImage(image: CarIcon): Banner.Builder

Adds a CarIcon to be displayed as an image to the trailing part of the banner.

A banner can have at most 2 trailing elements

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if there are already 2 trailing elements

build

Added in 1.8.0
fun build(): Banner

Constructs the Banner defined by this builder.

Throws
java.lang.IllegalStateException

if the title is null or empty

java.lang.IllegalStateException

if there are more than 4 elements across the banner's leading and trailing elements lists OR more than 2 of these elements are Actions

setBackground

Added in 1.9.0-alpha01
fun setBackground(background: Background): Banner.Builder

Sets the Background of the banner.

The background must conform to COLOR_ONLY.

Throws
java.lang.NullPointerException

if background is null

java.lang.IllegalArgumentException

if an unsupported background is added

setLeadingIcon

Added in 1.9.0-alpha01
fun setLeadingIcon(icon: CarIcon): Banner.Builder

Sets the leading element in this banner to be a CarIcon displayed as an icon.

Only a single leading icon or image can be set, so this will overwrite calls to setLeadingImage.

This is visually distinct from setLeadingImage as icons are smaller due to added padding, and are expected to be tinted.

Throws
java.lang.NullPointerException

if icon is null

setLeadingImage

Added in 1.9.0-alpha01
fun setLeadingImage(image: CarIcon): Banner.Builder

Sets the leading element in this banner to be a CarIcon displayed as an image.

Only a single leading icon or image can be set, so this will overwrite calls to setLeadingIcon.

This is visually distinct from setLeadingIcon as images have no added padding, and are not expected to be tinted.

Throws
java.lang.NullPointerException

if image is null

setOnClickListener

Added in 1.8.0
fun setOnClickListener(onClickListener: OnClickListener): Banner.Builder

Sets the OnClickListener to be called back when the banner is clicked.

Note that the listener relates to UI events and will be executed on the main thread using getMainLooper.

Throws
java.lang.NullPointerException

if onClickListener is null

setSubtitle

Added in 1.8.0
fun setSubtitle(subtitle: CarText): Banner.Builder

Sets the subtitle of the banner.

The subtitle allows TEXT_WITH_COLORS_AND_ICON spans to be added.

The subtitle is automatically truncated if it's too long.

Throws
java.lang.NullPointerException

if subtitle is null

java.lang.IllegalArgumentException

if any unsupported span types are added

setSubtitle

Added in 1.8.0
fun setSubtitle(subtitle: CharSequence): Banner.Builder

Sets the subtitle of the banner.

The subtitle allows TEXT_WITH_COLORS_AND_ICON spans to be added.

The subtitle is automatically truncated if it's too long.

Throws
java.lang.NullPointerException

if subtitle is null

java.lang.IllegalArgumentException

if any unsupported span types are added

setTitle

Added in 1.8.0
fun setTitle(title: CarText): Banner.Builder

Sets the title of the banner.

The title allows TEXT_AND_ICON spans to be added.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if any unsupported span types are added

setTitle

Added in 1.8.0
fun setTitle(title: CharSequence): Banner.Builder

Sets the title of the banner.

The title allows TEXT_AND_ICON spans to be added.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if any unsupported span types are added