CondensedItem.Builder


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


A builder for CondensedItem.

Summary

Public constructors

Public functions

CondensedItem

Constructs a CondensedItem from the current state of this builder.

CondensedItem.Builder
setIndexable(indexable: Boolean)

Sets whether this item can be included in indexed lists.

CondensedItem.Builder

Sets the leading image of the item.

CondensedItem.Builder

Sets the leading image of the item.

CondensedItem.Builder

Sets the OnClickListener for the item.

CondensedItem.Builder

Sets the CarProgressBar for the item.

CondensedItem.Builder

Sets the CondensedItemStyle for the item.

CondensedItem.Builder

Sets the text of the item.

CondensedItem.Builder

Sets the text of the item.

CondensedItem.Builder

Sets the title of the item.

CondensedItem.Builder

Sets the title of the item.

CondensedItem.Builder

Sets the trailing image of the item.

CondensedItem.Builder

Sets the trailing image of the item.

Public constructors

Builder

Added in 1.8.0
Builder()

Public functions

build

Added in 1.8.0
fun build(): CondensedItem

Constructs a CondensedItem from the current state of this builder.

Throws
java.lang.IllegalStateException

if mTitle, mText, mLeadingImage, AND mTrailingImage are all null.

java.lang.IllegalStateException

if both mText and mProgressBar are set.

setIndexable

Added in 1.9.0-alpha01
fun setIndexable(indexable: Boolean): CondensedItem.Builder

Sets whether this item can be included in indexed lists. By default, this is set to true.

The host creates indexed lists to help users navigate through long lists more easily by sorting, filtering, or some other means.

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 select a letter on a keyboard to jump to their playlists that start with that letter. When this happens, the list is reconstructed and sorted alphabetically, then shown to the user, jumping down to the letter. Items that are set to #setIndexable(false), do not show up in this new sorted list. Sticking with the media example, a media app may choose to hide things like "autogenerated playlists" from the list and only keep user created playlists.

Individual items can be set to be included or excluded from filtered lists, but it's also possible to enable/disable the creation of filtered lists as a whole via the template's API (eg. SectionedItemTemplate .Builder#setAlphabeticalIndexingStrategy(int)).

setLeadingImage

Added in 1.8.0
@CanIgnoreReturnValue
fun setLeadingImage(image: CarIcon): CondensedItem.Builder

Sets the leading image of the item.

The leading image will default to IMAGE_TYPE_SMALL.

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if image contains unsupported icon types

setLeadingImage

Added in 1.8.0
@CanIgnoreReturnValue
fun setLeadingImage(image: CarIcon, imageType: Int): CondensedItem.Builder

Sets the leading image of the item.

Parameters
image: CarIcon

the CarIcon for the leading image

imageType: Int

the CondensedItemImageType for the leading image

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if image contains unsupported icon types

setOnClickListener

Added in 1.8.0
@CanIgnoreReturnValue
fun setOnClickListener(onClickListener: OnClickListener): CondensedItem.Builder

Sets the OnClickListener for the item.

Throws
java.lang.NullPointerException

if onClickListener is null

setProgressBar

Added in 1.8.0
@CanIgnoreReturnValue
fun setProgressBar(progressBar: CarProgressBar): CondensedItem.Builder

Sets the CarProgressBar for the item.

Note: This field is mutually exclusive with setText. If both are set, build will throw an IllegalStateException.

Throws
java.lang.NullPointerException

if progressBar is null

setStyle

Added in 1.8.0
@CanIgnoreReturnValue
fun setStyle(style: CondensedItemStyle): CondensedItem.Builder

Sets the CondensedItemStyle for the item.

Throws
java.lang.NullPointerException

if style is null

setText

Added in 1.8.0
@CanIgnoreReturnValue
fun setText(text: CarText): CondensedItem.Builder

Sets the text of the item.

text must conform to CarTextConstraints.TEXT_WITH_COLORS_AND_ICON.

Note: This field is mutually exclusive with setProgressBar. If both are set, build will throw an IllegalStateException.

Throws
java.lang.NullPointerException

if text is null

java.lang.IllegalArgumentException

if text contains unsupported spans

setText

Added in 1.8.0
@CanIgnoreReturnValue
fun setText(text: CharSequence): CondensedItem.Builder

Sets the text of the item.

text must conform to CarTextConstraints.TEXT_WITH_COLORS_AND_ICON.

Note: This field is mutually exclusive with setProgressBar. If both are set, build will throw an IllegalStateException.

Throws
java.lang.NullPointerException

if text is null

java.lang.IllegalArgumentException

if text contains unsupported spans

setTitle

Added in 1.8.0
@CanIgnoreReturnValue
fun setTitle(title: CarText): CondensedItem.Builder

Sets the title of the item.

title must conform to CarTextConstraints.TEXT_AND_ICON.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

setTitle

Added in 1.8.0
@CanIgnoreReturnValue
fun setTitle(title: CharSequence): CondensedItem.Builder

Sets the title of the item.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

setTrailingImage

Added in 1.8.0
@CanIgnoreReturnValue
fun setTrailingImage(image: CarIcon): CondensedItem.Builder

Sets the trailing image of the item.

The trailing image will default to IMAGE_TYPE_SMALL.

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if image contains unsupported icon types

setTrailingImage

Added in 1.8.0
@CanIgnoreReturnValue
fun setTrailingImage(image: CarIcon, imageType: Int): CondensedItem.Builder

Sets the trailing image of the item.

Parameters
image: CarIcon

the CarIcon for the trailing image

imageType: Int

the CondensedItemImageType for the trailing image

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if image contains unsupported icon types