Banner.Builder


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


A builder of Banner.

Summary

Public constructors

Public methods

@NonNull Banner.Builder

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

@NonNull Banner.Builder

Adds an Action to the trailing part of the banner.

@NonNull 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.

@NonNull Banner.Builder
addTrailingImage(@NonNull CarIcon image, int imageType)

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

@NonNull Banner

Constructs the Banner defined by this builder.

@NonNull 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.

@NonNull Banner.Builder
setLeadingImage(@NonNull CarIcon image, int imageType)

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

@NonNull Banner.Builder

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

@NonNull Banner.Builder

Sets the BannerStyle of the banner.

@NonNull Banner.Builder

Sets the subtitle of the banner.

@NonNull Banner.Builder

Sets the subtitle of the banner.

@NonNull Banner.Builder

Sets the title of the banner.

@NonNull Banner.Builder

Sets the title of the banner.

Public constructors

Builder

Added in 1.8.0
public Builder()

Public methods

addBelowAction

Added in 1.8.0
public @NonNull Banner.Builder addBelowAction(@NonNull Action action)

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
public @NonNull Banner.Builder addTrailingAction(@NonNull Action action)

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
public @NonNull Banner.Builder addTrailingImage(@NonNull CarIcon image)

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
public @NonNull Banner.Builder addTrailingImage(@NonNull CarIcon image, int imageType)

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
@NonNull CarIcon image

the CarIcon for the trailing image

int imageType

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
public @NonNull Banner build()

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
public @NonNull Banner.Builder setLeadingImage(@NonNull CarIcon image)

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
public @NonNull Banner.Builder setLeadingImage(@NonNull CarIcon image, int imageType)

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
@NonNull CarIcon image

the CarIcon for the leading image

int imageType

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
public @NonNull Banner.Builder setOnClickListener(@NonNull OnClickListener onClickListener)

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
public @NonNull Banner.Builder setStyle(@NonNull BannerStyle style)

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
public @NonNull Banner.Builder setSubtitle(@NonNull CarText subtitle)

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
public @NonNull Banner.Builder setSubtitle(@NonNull CharSequence subtitle)

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
public @NonNull Banner.Builder setTitle(@NonNull CarText title)

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
public @NonNull Banner.Builder setTitle(@NonNull CharSequence title)

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