GridRowBuilder.CellBuilder

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 functions

GridRowBuilder.CellBuilder
addImage(image: IconCompat, imageMode: Int)

Adds an image to the cell.

GridRowBuilder.CellBuilder
addImage(image: IconCompat?, imageMode: Int, isLoading: Boolean)

Adds an image to the cell.

GridRowBuilder.CellBuilder

Adds text to the cell.

GridRowBuilder.CellBuilder
addOverlayText(text: CharSequence?, isLoading: Boolean)

Adds text to the cell.

GridRowBuilder.CellBuilder

Adds text to the cell.

GridRowBuilder.CellBuilder
addText(text: CharSequence?, isLoading: Boolean)

Adds text to the cell.

GridRowBuilder.CellBuilder

Adds text to the cell.

GridRowBuilder.CellBuilder
addTitleText(text: CharSequence?, isLoading: Boolean)

Adds text to the cell.

GridRowBuilder.CellBuilder

Sets the content description for this cell.

GridRowBuilder.CellBuilder

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

GridRowBuilder.CellBuilder

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

GridRowBuilder.CellBuilder

Sets the SliceAction for the cell.

Public constructors

CellBuilder

Added in 1.1.0-alpha02
CellBuilder()

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

Public functions

addImage

Added in 1.1.0-alpha02
fun addImage(image: IconCompat, imageMode: Int): GridRowBuilder.CellBuilder

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
image: IconCompat

the image to display in the cell.

imageMode: Int

the mode that image should be displayed in.

addImage

Added in 1.1.0-alpha02
fun addImage(image: IconCompat?, imageMode: Int, isLoading: Boolean): GridRowBuilder.CellBuilder

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
image: IconCompat?

the image to display in the cell.

imageMode: Int

the mode that image should be displayed in.

isLoading: Boolean

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

addOverlayText

Added in 1.1.0-alpha02
fun addOverlayText(text: CharSequence): GridRowBuilder.CellBuilder

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
fun addOverlayText(text: CharSequence?, isLoading: Boolean): GridRowBuilder.CellBuilder

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
isLoading: Boolean

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

addText

Added in 1.1.0-alpha02
fun addText(text: CharSequence): GridRowBuilder.CellBuilder

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
fun addText(text: CharSequence?, isLoading: Boolean): GridRowBuilder.CellBuilder

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
isLoading: Boolean

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

addTitleText

Added in 1.1.0-alpha02
fun addTitleText(text: CharSequence): GridRowBuilder.CellBuilder

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
fun addTitleText(text: CharSequence?, isLoading: Boolean): GridRowBuilder.CellBuilder

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
isLoading: Boolean

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

setContentDescription

Added in 1.1.0-alpha02
fun setContentDescription(description: CharSequence): GridRowBuilder.CellBuilder

Sets the content description for this cell.

setContentIntent

Added in 1.1.0-alpha02
fun setContentIntent(callback: RemoteCallback): GridRowBuilder.CellBuilder

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

setContentIntent

Added in 1.1.0-alpha02
fun setContentIntent(intent: PendingIntent): GridRowBuilder.CellBuilder

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

setSliceAction

Added in 1.1.0-alpha02
fun setSliceAction(action: SliceAction): GridRowBuilder.CellBuilder

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.