GridRowBuilder.CellBuilder

public class GridRowBuilder.CellBuilder

Known direct subclasses
CellBuilderDsl

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


Builder to construct a cell. A cell can be added as an item to GridRowBuilder via addCell.

A cell supports up to two lines of text and one image. Content added to a cell will be displayed in the order that the content is added to it. For example, the below code would construct a cell with "First text", and image below it, and then "Second text" below the image.

CellBuilder cb = new CellBuilder(parent, sliceUri);
cb.addText("First text")
  .addImage(middleIcon)
  .addText("Second text");

A cell supports a couple of image types:

  • ICON_IMAGE - icon images are expected to be tintable and are shown at a standard icon size.
  • SMALL_IMAGE - small images are not tinted and are shown at a small size.
  • LARGE_IMAGE - large images are not tinted and are shown as large as they can be, in a CENTER_CROP

Summary

Public constructors

Create a builder which will construct a slice displayed as a cell in a grid.

Public methods

@NonNull GridRowBuilder.CellBuilder
addImage(@NonNull IconCompat image, int imageMode)

Adds an image to the cell.

@NonNull GridRowBuilder.CellBuilder
addImage(@Nullable IconCompat image, int imageMode, boolean isLoading)

Adds an image to the cell.

@NonNull GridRowBuilder.CellBuilder

Adds text to the cell.

@NonNull GridRowBuilder.CellBuilder
addOverlayText(@Nullable CharSequence text, boolean isLoading)

Adds text to the cell.

@NonNull GridRowBuilder.CellBuilder

Adds text to the cell.

@NonNull GridRowBuilder.CellBuilder
addText(@Nullable CharSequence text, boolean isLoading)

Adds text to the cell.

@NonNull GridRowBuilder.CellBuilder

Adds text to the cell.

@NonNull GridRowBuilder.CellBuilder
addTitleText(@Nullable CharSequence text, boolean isLoading)

Adds text to the cell.

@NonNull GridRowBuilder.CellBuilder

Sets the content description for this cell.

@NonNull GridRowBuilder.CellBuilder

Sets the action to be invoked if the user taps on this cell in the row.

@NonNull GridRowBuilder.CellBuilder

Sets the action to be invoked if the user taps on this cell in the row.

@NonNull GridRowBuilder.CellBuilder

Sets the SliceAction for the cell.

Public constructors

CellBuilder

Added in 1.1.0-alpha02
public CellBuilder()

Create a builder which will construct a slice displayed as a cell in a grid.

Public methods

addImage

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addImage(@NonNull IconCompat image, int imageMode)

Adds an image to the cell. There can be at most one image, the first one added will be used, others will be ignored.

Parameters
@NonNull IconCompat image

the image to display in the cell.

int imageMode

the mode that image should be displayed in.

addImage

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addImage(@Nullable IconCompat image, int imageMode, boolean isLoading)

Adds an image to the cell. There can be at most one image, the first one added will be used, others will be ignored.

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

Parameters
@Nullable IconCompat image

the image to display in the cell.

int imageMode

the mode that image should be displayed in.

boolean isLoading

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

addOverlayText

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addOverlayText(@NonNull CharSequence text)

Adds text to the cell. Text added with this method will be overlaid in the image in the cell. There can be only one overlay text, the first added will be used, others will be ignored.

addOverlayText

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addOverlayText(@Nullable CharSequence text, boolean isLoading)

Adds text to the cell. Text added with this method will be overlaid in the image in the cell. There can be only one overlay text, the first added will be used, others will be ignored.

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.

addText

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addText(@NonNull CharSequence text)

Adds text to the cell. There can be at most two text items, the first two added will be used, others will be ignored.

addText

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addText(@Nullable CharSequence text, boolean isLoading)

Adds text to the cell. There can be at most two text items, the first two added will be used, others will be ignored.

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.

addTitleText

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addTitleText(@NonNull CharSequence text)

Adds text to the cell. Text added with this method will be styled as a title. There can be at most two text items, the first two added will be used, others will be ignored.

addTitleText

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder addTitleText(@Nullable CharSequence text, boolean isLoading)

Adds text to the cell. Text added with this method will be styled as a title. There can be at most two text items, the first two added will be used, others will be ignored.

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.

setContentDescription

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder setContentDescription(@NonNull CharSequence description)

Sets the content description for this cell.

setContentIntent

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder setContentIntent(@NonNull RemoteCallback callback)

Sets the action to be invoked if the user taps on this cell in the row.

setContentIntent

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder setContentIntent(@NonNull PendingIntent intent)

Sets the action to be invoked if the user taps on this cell in the row.

setSliceAction

Added in 1.1.0-alpha02
public @NonNull GridRowBuilder.CellBuilder setSliceAction(@NonNull SliceAction action)

Sets the SliceAction for the cell. It could be an action or a toggle button or a date/time picker. The actionTitle and icon image of the SliceAction will only be used when there is no other text or image in the cell.