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

public final class TileRenderer.Builder

Builder for TileRenderer.

This interface is deprecated.

Use < with TileRenderer.

Public constructors

TileRenderer(
    @NonNull Context uiContext,
    @NonNull Executor loadActionExecutor,
    @NonNull Consumer<StateBuilders.State> loadActionListener
)

Constructor for TileRenderer.

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.Builder 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.Builder which accepts Layout and Resources in inflateAsync method.

Public methods

@NonNull Executor

Returns the Executor for loadActionListener.

@NonNull Consumer<StateBuilders.State>

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

@NonNull Map<PlatformDataProviderSet<PlatformDataKey<Object>>>

Returns the platform data providers that will be registered for this Tile instance.

int

Returns the theme to use for this Tile instance.

@NonNull Context

Returns the Context suitable for interacting with the UI.

@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
)

Constructor for TileRenderer.

It is recommended to use the new TileRenderer.Builder instead.

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

getLoadActionExecutor

Added in 1.4.0
public @NonNull Executor getLoadActionExecutor()

Returns the Executor for loadActionListener.

getLoadActionListener

Added in 1.4.0
public @NonNull Consumer<StateBuilders.StategetLoadActionListener()

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

getPlatformDataProviders

Added in 1.4.0
public @NonNull Map<PlatformDataProviderSet<PlatformDataKey<Object>>> getPlatformDataProviders()

Returns the platform data providers that will be registered for this Tile instance.

getTilesTheme

Added in 1.4.0
public int getTilesTheme()

Returns the theme to use for this Tile instance. This can be used to customise things like the default font family. Defaults to zero (default theme) if not specified by setTilesTheme.

getUiContext

Added in 1.4.0
public @NonNull Context getUiContext()

Returns the Context suitable for interacting with the UI.

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.