belongs to Maven artifact androidx.slice:slice-builders:1.0.0-alpha1

GridRowBuilder

public class GridRowBuilder
extends TemplateSliceBuilder

java.lang.Object
   ↳ androidx.slice.builders.TemplateSliceBuilder
     ↳ androidx.slice.builders.GridRowBuilder


Builder to construct a grid row which may be added as a row to ListBuilder.

A grid row supports cells of vertically laid out content in a single row. Each cell can contain a combination of text and images and is constructed using a GridRowBuilder.CellBuilder.

A grid supports a couple of image types:

If the first row of your slice was created with GridRowBuilder then there are a couple of extra considerations you should take for when the slice is displayed in different modes, particularly:

If more cells are added to the grid row than can be displayed, the cells will be cut off. Using addSeeMoreAction(PendingIntent) you can specify an action to take the user to see the rest of the content, this will take up space as a cell item in a row if added.

Summary

Nested classes

class GridRowBuilder.CellBuilder

Builder to construct a cell. 

Public constructors

GridRowBuilder(ListBuilder parent)

Create a builder which will construct a slice displayed in a grid format.

Public methods

GridRowBuilder addCell(Consumer<GridRowBuilder.CellBuilder> c)

Add a cell to the grid builder.

GridRowBuilder addCell(GridRowBuilder.CellBuilder builder)

Add a cell to the grid builder.

GridRowBuilder addSeeMoreAction(PendingIntent intent)

This method is deprecated. TO BE REMOVED

GridRowBuilder addSeeMoreCell(Consumer<GridRowBuilder.CellBuilder> c)

This method is deprecated. TO BE REMOVED

GridRowBuilder addSeeMoreCell(GridRowBuilder.CellBuilder builder)

This method is deprecated. TO BE REMOVED

GridRowBuilder setContentDescription(CharSequence description)

Sets the content description for the entire grid row.

GridRowBuilder setPrimaryAction(SliceAction action)

Sets the intent to send when the whole grid row is clicked.

GridRowBuilder setSeeMoreAction(PendingIntent intent)

If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off.

GridRowBuilder setSeeMoreCell(Consumer<GridRowBuilder.CellBuilder> c)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

GridRowBuilder setSeeMoreCell(GridRowBuilder.CellBuilder builder)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

Inherited methods

Public constructors

GridRowBuilder

GridRowBuilder (ListBuilder parent)

Create a builder which will construct a slice displayed in a grid format.

Parameters
parent ListBuilder: The builder constructing the parent slice.

Public methods

addCell

GridRowBuilder addCell (Consumer<GridRowBuilder.CellBuilder> c)

Add a cell to the grid builder.

Parameters
c Consumer

Returns
GridRowBuilder

addCell

GridRowBuilder addCell (GridRowBuilder.CellBuilder builder)

Add a cell to the grid builder.

Parameters
builder GridRowBuilder.CellBuilder

Returns
GridRowBuilder

addSeeMoreAction

GridRowBuilder addSeeMoreAction (PendingIntent intent)

This method is deprecated.
TO BE REMOVED

If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off. The action added here should take the user to an activity to see all of the content, and will be invoked when the "see more" affordance is tapped.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
intent PendingIntent

Returns
GridRowBuilder

addSeeMoreCell

GridRowBuilder addSeeMoreCell (Consumer<GridRowBuilder.CellBuilder> c)

This method is deprecated.
TO BE REMOVED

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

This method should only be used if you want to display a custom cell to indicate more content, consider using addSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have GridRowBuilder.CellBuilder.setContentIntent(PendingIntent) specified to take the user to an activity to see all of the content.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
c Consumer

Returns
GridRowBuilder

addSeeMoreCell

GridRowBuilder addSeeMoreCell (GridRowBuilder.CellBuilder builder)

This method is deprecated.
TO BE REMOVED

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

This method should only be used if you want to display a custom cell to indicate more content, consider using addSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have GridRowBuilder.CellBuilder.setContentIntent(PendingIntent) specified to take the user to an activity to see all of the content.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
builder GridRowBuilder.CellBuilder

Returns
GridRowBuilder

setContentDescription

GridRowBuilder setContentDescription (CharSequence description)

Sets the content description for the entire grid row.

Parameters
description CharSequence

Returns
GridRowBuilder

setPrimaryAction

GridRowBuilder setPrimaryAction (SliceAction action)

Sets the intent to send when the whole grid row is clicked.

If all the cells in the grid have specified a setPrimaryAction(SliceAction) then the action set here on the GridRowBuilder may not ever be invoked.

If this grid row is the first row in ListBuilder, the action set here will be used to represent the slice when presented in SliceView.MODE_SHORTCUT.

Parameters
action SliceAction

Returns
GridRowBuilder

setSeeMoreAction

GridRowBuilder setSeeMoreAction (PendingIntent intent)

If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off. The action added here should take the user to an activity to see all of the content, and will be invoked when the "see more" affordance is tapped.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
intent PendingIntent

Returns
GridRowBuilder

setSeeMoreCell

GridRowBuilder setSeeMoreCell (Consumer<GridRowBuilder.CellBuilder> c)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

This method should only be used if you want to display a custom cell to indicate more content, consider using addSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have GridRowBuilder.CellBuilder.setContentIntent(PendingIntent) specified to take the user to an activity to see all of the content.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
c Consumer

Returns
GridRowBuilder

setSeeMoreCell

GridRowBuilder setSeeMoreCell (GridRowBuilder.CellBuilder builder)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

This method should only be used if you want to display a custom cell to indicate more content, consider using addSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have GridRowBuilder.CellBuilder.setContentIntent(PendingIntent) specified to take the user to an activity to see all of the content.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
builder GridRowBuilder.CellBuilder

Returns
GridRowBuilder