Banner.Builder


@RequiresCarApi(value = 9)
@ExperimentalCarApi
class Banner.Builder


A builder of Banner.

Summary

Public constructors

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 IMAGE_TYPE_MEDIUM image at the trailing part of the Banner, not expected to be tinted.

Banner.Builder
addTrailingImage(image: CarIcon, imageType: Int)

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 leading element in this banner to be a CarIcon displayed as an IMAGE_TYPE_MEDIUM image, not expected to be tinted.

Banner.Builder
setLeadingImage(image: CarIcon, imageType: Int)

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

Sets the BannerStyle of the banner.

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()

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.

Below actions cannot be used in combination with a large image.

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

addTrailingImage

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

Adds a CarIcon to be displayed as an IMAGE_TYPE_MEDIUM image at the trailing part of the Banner, not expected to be tinted.

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

addTrailingImage

Added in 1.9.0-alpha02
fun addTrailingImage(image: CarIcon, imageType: Int): 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.

A large image cannot be used in combination with addBelowAction.

A large trailing image cannot be used in combination with another large trailing image.

Parameters
image: CarIcon

the CarIcon for the trailing image

imageType: Int

one of IMAGE_TYPE_SMALL, IMAGE_TYPE_MEDIUM, IMAGE_TYPE_LARGE

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if there are already 2 trailing elements

java.lang.IllegalArgumentException

if a large trailing image is combined with anything other than a trailing small image or action

build

Added in 1.8.0
fun build(): Banner

Constructs the Banner defined by this builder.

Throws
java.lang.IllegalArgumentException

if the title is null or empty

java.lang.IllegalArgumentException

if below actions are used in combination with a large image

setLeadingImage

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

Sets the leading element in this banner to be a CarIcon displayed as an IMAGE_TYPE_MEDIUM image, not expected to be tinted.

Only a single leading image can be set. Subsequent calls will overwrite previous calls.

Throws
java.lang.NullPointerException

if image is null

setLeadingImage

Added in 1.9.0-alpha02
fun setLeadingImage(image: CarIcon, imageType: Int): 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. Subsequent calls will overwrite previous calls.

A large image cannot be used in combination with addBelowAction.

Parameters
image: CarIcon

the CarIcon for the leading image

imageType: Int

one of IMAGE_TYPE_SMALL, IMAGE_TYPE_MEDIUM, IMAGE_TYPE_LARGE

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

setStyle

Added in 1.9.0-alpha02
fun setStyle(style: BannerStyle): Banner.Builder

Sets the BannerStyle of the banner.

If a style is not provided via this method, a host default style will be used.

Throws
java.lang.NullPointerException

if style 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