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.BuilderBuilder for |
public interface TileRenderer.LoadActionListenerThis interface is deprecated. Use |
Public constructors |
|---|
TileRenderer(Constructor for |
This method is deprecated. Use |
This method is deprecated. Use |
Public methods |
|
|---|---|
@NonNull Executor |
Returns the |
@NonNull Consumer<StateBuilders.State> |
Returns the Listener for clicks that will cause the contents to be reloaded. |
@NonNull Map<PlatformDataProvider, Set<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 |
@Nullable View |
This method is deprecated. Use |
@NonNull ListenableFuture<View> |
inflateAsync(Inflates a Tile into |
void |
setState(Sets the state for the current (and future) layouts. |
Public constructors
TileRenderer
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.
publicTileRenderer(
@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 |
@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 |
@NonNull TileRenderer.LoadActionListener loadActionListener |
Listener for clicks that will cause the contents to be reloaded. |
publicTileRenderer(
@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 |
@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 |
@NonNull TileRenderer.LoadActionListener loadActionListener |
Listener for clicks that will cause the contents to be reloaded. |
Public methods
getLoadActionExecutor
public @NonNull Executor getLoadActionExecutor()
Returns the Executor for loadActionListener.
getLoadActionListener
public @NonNull Consumer<StateBuilders.State> getLoadActionListener()
Returns the Listener for clicks that will cause the contents to be reloaded.
getPlatformDataProviders
public @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<Object>>> getPlatformDataProviders()
Returns the platform data providers that will be registered for this Tile instance.
getTilesTheme
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
public @NonNull Context getUiContext()
Returns the Context suitable for interacting with the UI.
inflateAsync
public @NonNull ListenableFuture<View> inflateAsync(
@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
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 |