ListBuilder.RowBuilder


public class ListBuilder.RowBuilder

Known direct subclasses
RowBuilderDsl

Helper class annotated with @SliceMarker, which is annotated with @DslMarker.


Builder to construct a row. A row can be added as an item to ListBuilder via addRow.

A row supports:

  • Title item - The title item can be a timestamp, image, or a SliceAction. It appears with at the start of the row. There can only be one title item added to a row.
  • Title - Single line of text formatted as a title, see setTitle.
  • Subtitle - Single line of text below the title (if one exists) and is formatted as normal text, see setSubtitle.
  • End item - End items appear at the end of the row. There can be multiple end items that show depending on available width. End items can be a timestamp, image, or a tappable icon.
  • Primary action - The primary action for the row, this is the action that will be sent when the row is clicked. This is set via setPrimaryAction. If this is the only row or first row of the slice, then the action set here will be used to represent the slice shown in MODE_SMALL.
There are a couple of restrictions to how content can be added to a row:
  • End items cannot contain a mixture of SliceActions and Icons.
  • There can only be one timestamp added to the row.
See also
addRow

Summary

Public constructors

Builder to construct a row.

Builder to construct a normal row.

Public methods

@NonNull ListBuilder.RowBuilder

Adds an action to the end items of the row builder.

@NonNull ListBuilder.RowBuilder
addEndItem(long timeStamp)

Adds a timestamp to the end items of the row builder.

@NonNull ListBuilder.RowBuilder
addEndItem(@NonNull SliceAction action, boolean isLoading)

Adds an action to the end items of the row builder.

@NonNull ListBuilder.RowBuilder
addEndItem(@NonNull IconCompat icon, int imageMode)

Adds an icon to the end items of the row builder.

@NonNull ListBuilder.RowBuilder
addEndItem(@Nullable IconCompat icon, int imageMode, boolean isLoading)

Adds an icon to the end items of the row builder.

@NonNull ListBuilder.RowBuilder

Sets the content description for the row.

@NonNull ListBuilder.RowBuilder
setEndOfSection(boolean isEndOfSection)

Indicate that this row is an end for a section.

@NonNull ListBuilder.RowBuilder
setLayoutDirection(int layoutDirection)

Sets the desired layout direction for the content in this row.

@NonNull ListBuilder.RowBuilder

The action specified here will be sent when the whole row is clicked.

@NonNull ListBuilder.RowBuilder

Sets the subtitle for the row builder.

@NonNull ListBuilder.RowBuilder
setSubtitle(@Nullable CharSequence subtitle, boolean isLoading)

Sets the subtitle for the row builder.

@NonNull ListBuilder.RowBuilder

Sets the title for the row builder.

@NonNull ListBuilder.RowBuilder
setTitle(@Nullable CharSequence title, boolean isLoading)

Sets the title for the row builder.

@NonNull ListBuilder.RowBuilder

Sets the title item to be a tappable icon.

@NonNull ListBuilder.RowBuilder
setTitleItem(long timeStamp)

Sets the title item to be the provided timestamp.

@NonNull ListBuilder.RowBuilder
setTitleItem(@NonNull SliceAction action, boolean isLoading)

Sets the title item to be a tappable icon.

@NonNull ListBuilder.RowBuilder
setTitleItem(@NonNull IconCompat icon, int imageMode)

Sets the title item to be the provided icon.

@NonNull ListBuilder.RowBuilder
setTitleItem(@Nullable IconCompat icon, int imageMode, boolean isLoading)

Sets the title item to be the provided icon.

Public constructors

RowBuilder

Added in 1.1.0-alpha02
public RowBuilder()

Builder to construct a row.

RowBuilder

Added in 1.1.0-alpha02
public RowBuilder(@NonNull Uri uri)

Builder to construct a normal row.

Parameters
@NonNull Uri uri

Uri to tag for this slice.

Public methods

addEndItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder addEndItem(@NonNull SliceAction action)

Adds an action to the end items of the row builder. A mixture of icons and actions is not permitted. If an icon has already been added, this will throw IllegalArgumentException.

addEndItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder addEndItem(long timeStamp)

Adds a timestamp to the end items of the row builder. Only one timestamp can be added, if one is already added this will throw IllegalArgumentException.

addEndItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder addEndItem(@NonNull SliceAction action, boolean isLoading)

Adds an action to the end items of the row builder. A mixture of icons and actions is not permitted. If an icon has already been added, this will throw IllegalArgumentException.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
boolean isLoading

indicates whether the app is doing work to load the added content in the background or not.

addEndItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder addEndItem(@NonNull IconCompat icon, int imageMode)

Adds an icon to the end items of the row builder.

Parameters
@NonNull IconCompat icon

the image to display.

int imageMode

the mode that image should be displayed in.

addEndItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder addEndItem(@Nullable IconCompat icon, int imageMode, boolean isLoading)

Adds an icon to the end items of the row builder.

When set to true, the parameter isLoading indicates that the app is doing work to load this content in the background, in this case the template displays a placeholder until updated.

Parameters
@Nullable IconCompat icon

the image to display.

int imageMode

the mode that image should be displayed in.

boolean isLoading

whether this content is being loaded in the background.

setContentDescription

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setContentDescription(@NonNull CharSequence description)

Sets the content description for the row.

setEndOfSection

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setEndOfSection(boolean isEndOfSection)

Indicate that this row is an end for a section.

setLayoutDirection

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setLayoutDirection(int layoutDirection)

Sets the desired layout direction for the content in this row.

Parameters
int layoutDirection

the layout direction to set.

setPrimaryAction

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setPrimaryAction(@NonNull SliceAction action)

The action specified here will be sent when the whole row is clicked.

If this is the first row in a ListBuilder this action will also be used to define the MODE_SHORTCUT representation of the slice.

setSubtitle

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setSubtitle(@NonNull CharSequence subtitle)

Sets the subtitle for the row builder. A subtitle should fit on a single line and is ellipsized if too long.

setSubtitle

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setSubtitle(@Nullable CharSequence subtitle, boolean isLoading)

Sets the subtitle for the row builder. A subtitle should fit on a single line and is ellipsized if too long.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
boolean isLoading

indicates whether the app is doing work to load the added content in the background or not.

setTitle

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitle(@NonNull CharSequence title)

Sets the title for the row builder. A title should fit on a single line and is ellipsized if too long.

setTitle

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitle(@Nullable CharSequence title, boolean isLoading)

Sets the title for the row builder. A title should fit on a single line and is ellipsized if too long.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
boolean isLoading

indicates whether the app is doing work to load the added content in the background or not.

setTitleItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitleItem(@NonNull SliceAction action)

Sets the title item to be a tappable icon. There can only be one title item, this will replace any other title items that may have been set.

setTitleItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitleItem(long timeStamp)

Sets the title item to be the provided timestamp. Only one timestamp can be added, if one is already added this will throw IllegalArgumentException.

There can only be one title item, this will replace any other title items that may have been set.

setTitleItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitleItem(@NonNull SliceAction action, boolean isLoading)

Sets the title item to be a tappable icon. There can only be one title item, this will replace any other title items that may have been set.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
boolean isLoading

indicates whether the app is doing work to load the added content in the background or not.

setTitleItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitleItem(@NonNull IconCompat icon, int imageMode)

Sets the title item to be the provided icon. There can only be one title item, this will replace any other title items that may have been set.

Parameters
@NonNull IconCompat icon

the image to display.

int imageMode

the mode that image should be displayed in.

setTitleItem

Added in 1.1.0-alpha02
public @NonNull ListBuilder.RowBuilder setTitleItem(@Nullable IconCompat icon, int imageMode, boolean isLoading)

Sets the title item to be the provided icon. There can only be one title item, this will replace any other title items that may have been set.

When set to true, the parameter isLoading indicates that the app is doing work to load this content in the background, in this case the template displays a placeholder until updated.

Parameters
@Nullable IconCompat icon

the image to display.

int imageMode

the mode that image should be displayed in.

boolean isLoading

whether this content is being loaded in the background.