CondensedItem.Builder


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


A builder for CondensedItem.

Summary

Public constructors

Public methods

@NonNull CondensedItem

Constructs a CondensedItem from the current state of this builder.

@NonNull CondensedItem.Builder
setIndexable(boolean indexable)

Sets whether this item can be included in indexed lists.

@NonNull CondensedItem.Builder

Sets the leading image of the item.

@NonNull CondensedItem.Builder

Sets the leading image of the item.

@NonNull CondensedItem.Builder

Sets the OnClickListener for the item.

@NonNull CondensedItem.Builder

Sets the CarProgressBar for the item.

@NonNull CondensedItem.Builder

Sets the CondensedItemStyle for the item.

@NonNull CondensedItem.Builder

Sets the text of the item.

@NonNull CondensedItem.Builder

Sets the text of the item.

@NonNull CondensedItem.Builder

Sets the title of the item.

@NonNull CondensedItem.Builder

Sets the title of the item.

@NonNull CondensedItem.Builder

Sets the trailing image of the item.

@NonNull CondensedItem.Builder

Sets the trailing image of the item.

Public constructors

Builder

Added in 1.8.0
public Builder()

Public methods

build

Added in 1.8.0
public @NonNull CondensedItem build()

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
public @NonNull CondensedItem.Builder setIndexable(boolean indexable)

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

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

Sets the leading image of the item.

Parameters
@NonNull CarIcon image

the CarIcon for the leading image

int imageType

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

Sets the OnClickListener for the item.

Throws
java.lang.NullPointerException

if onClickListener is null

setProgressBar

Added in 1.8.0
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setProgressBar(@NonNull CarProgressBar progressBar)

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

Sets the CondensedItemStyle for the item.

Throws
java.lang.NullPointerException

if style is null

setText

Added in 1.8.0
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setText(@NonNull CarText text)

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
public @NonNull CondensedItem.Builder setText(@NonNull CharSequence text)

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

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

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

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

Sets the trailing image of the item.

Parameters
@NonNull CarIcon image

the CarIcon for the trailing image

int imageType

the CondensedItemImageType for the trailing image

Throws
java.lang.NullPointerException

if image is null

java.lang.IllegalArgumentException

if image contains unsupported icon types