TileRenderer

public final class TileRenderer


Renderer for Wear Tiles.

This variant uses Android views to represent the contents of the Wear Tile.

Summary

Nested types

This interface is deprecated.

Use < with TileRenderer.

Public constructors

TileRenderer(
    @NonNull Context uiContext,
    @NonNull Executor loadActionExecutor,
    @NonNull Consumer<StateBuilders.State> loadActionListener
)
TileRenderer(
    @NonNull Context uiContext,
    @NonNull LayoutElementBuilders.Layout layout,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull Executor loadActionExecutor,
    @NonNull TileRenderer.LoadActionListener loadActionListener
)

This method is deprecated.

Use TileRenderer which accepts Layout and Resources in inflateAsync method.

TileRenderer(
    @NonNull Context uiContext,
    @NonNull LayoutElementBuilders.Layout layout,
    @StyleRes int tilesTheme,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull Executor loadActionExecutor,
    @NonNull TileRenderer.LoadActionListener loadActionListener
)

This method is deprecated.

Use TileRenderer which accepts Layout and Resources in inflateAsync method.

Public methods

@Nullable View

This method is deprecated.

Use inflateAsync instead.

@NonNull ListenableFuture<View>

Inflates a Tile into parent.

void

Sets the state for the current (and future) layouts.

Public constructors

TileRenderer

Added in 1.2.0
public TileRenderer(
    @NonNull Context uiContext,
    @NonNull Executor loadActionExecutor,
    @NonNull Consumer<StateBuilders.State> loadActionListener
)
Parameters
@NonNull Context uiContext

A Context suitable for interacting with the UI.

@NonNull Executor loadActionExecutor

Executor for loadActionListener.

@NonNull Consumer<StateBuilders.State> loadActionListener

Listener for clicks that will cause the contents to be reloaded.

TileRenderer

Added in 1.0.0
Deprecated in 1.2.0
public TileRenderer(
    @NonNull Context uiContext,
    @NonNull LayoutElementBuilders.Layout layout,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull Executor loadActionExecutor,
    @NonNull TileRenderer.LoadActionListener loadActionListener
)

Default constructor.

Parameters
@NonNull Context uiContext

A Context suitable for interacting with the UI.

@NonNull LayoutElementBuilders.Layout layout

The portion of the Tile to render.

@NonNull ResourceBuilders.Resources resources

The resources for the Tile.

@NonNull Executor loadActionExecutor

Executor for loadActionListener.

@NonNull TileRenderer.LoadActionListener loadActionListener

Listener for clicks that will cause the contents to be reloaded.

TileRenderer

Added in 1.0.0
Deprecated in 1.2.0
public TileRenderer(
    @NonNull Context uiContext,
    @NonNull LayoutElementBuilders.Layout layout,
    @StyleRes int tilesTheme,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull Executor loadActionExecutor,
    @NonNull TileRenderer.LoadActionListener loadActionListener
)

Default constructor.

Parameters
@NonNull Context uiContext

A Context suitable for interacting with the UI.

@NonNull LayoutElementBuilders.Layout layout

The portion of the Tile to render.

@StyleRes int tilesTheme

The theme to use for this Tile instance. This can be used to customise things like the default font family. Pass 0 to use the default theme.

@NonNull ResourceBuilders.Resources resources

The resources for the Tile.

@NonNull Executor loadActionExecutor

Executor for loadActionListener.

@NonNull TileRenderer.LoadActionListener loadActionListener

Listener for clicks that will cause the contents to be reloaded.

Public methods

inflate

Added in 1.0.0
Deprecated in 1.2.0
public @Nullable View inflate(@NonNull ViewGroup parent)

Inflates a Tile into parent.

Parameters
@NonNull ViewGroup parent

The view to attach the tile into.

Returns
@Nullable View

The first child that was inflated. This may be null if the Layout is empty or the top-level LayoutElement has no inner set, or the top-level LayoutElement contains an unsupported inner type.

inflateAsync

Added in 1.2.0
public @NonNull ListenableFuture<ViewinflateAsync(
    @NonNull LayoutElementBuilders.Layout layout,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull ViewGroup parent
)

Inflates a Tile into parent.

Parameters
@NonNull LayoutElementBuilders.Layout layout

The portion of the Tile to render.

@NonNull ResourceBuilders.Resources resources

The resources for the Tile.

@NonNull ViewGroup parent

The view to attach the tile into.

Returns
@NonNull ListenableFuture<View>

The future with the first child that was inflated. This may be null if the Layout is empty or the top-level LayoutElement has no inner set, or the top-level LayoutElement contains an unsupported inner type.

setState

Added in 1.2.0
public void setState(
    @NonNull Map<AppDataKey<Object>, DynamicDataBuilders.DynamicDataValue<Object>> newState
)

Sets the state for the current (and future) layouts. This is equivalent to setting the tile state via addKeyToValueMapping

Parameters
@NonNull Map<AppDataKey<Object>, DynamicDataBuilders.DynamicDataValue<Object>> newState

the state to use for the current layout (and any future layouts). This value will replace any previously set state.

Throws
java.lang.IllegalStateException

if number of newState entries is greater than getMaxStateEntryCount.