ListenableCanvasRenderer

public abstract class ListenableCanvasRenderer extends Renderer.CanvasRenderer


ListenableFuture-based compatibility wrapper around Renderer.CanvasRenderer's suspending methods.

Summary

Public constructors

ListenableCanvasRenderer(
    @NonNull SurfaceHolder surfaceHolder,
    @NonNull CurrentUserStyleRepository currentUserStyleRepository,
    @NonNull WatchState watchState,
    int canvasType,
    @IntRange(from = 0, to = 60000) long interactiveDrawModeUpdateDelayMillis,
    boolean clearWithBackgroundTintBeforeRenderingHighlightLayer
)

Public methods

void

Perform UiThread specific initialization.

@NonNull ListenableFuture<Unit>

Perform UiThread specific initialization.

Inherited methods

From androidx.wear.watchface.Renderer
final @NonNull Collection<@NonNull Pair<@NonNull Integer, @NonNull ContentDescriptionLabel>>

Accessibility ContentDescriptionLabel for any rendered watch face elements other than the time and ComplicationSlots which are generated automatically.

final float

The center x coordinate of the SurfaceHolder this Renderer renders into.

final float

The center y coordinate of the SurfaceHolder this Renderer renders into.

final long

The interval in milliseconds between frames in interactive DrawModes.

@NonNull Rect

This method is used for accessibility support to describe the portion of the screen containing the main clock element.

final @NonNull RenderParameters

The current RenderParameters.

final @NonNull Rect

The bounds of the SurfaceHolder this Renderer renders into.

final @NonNull SurfaceHolder

The SurfaceHolder that renderInternal will draw into.

final WatchFaceColors

Representative WatchFaceColors which are made available to system clients via androidx.wear.watchface.client.InteractiveWatchFaceClient.OnWatchFaceColorsListener.

final void

Schedules a call to either CanvasRenderer.render or GlesRenderer.render to draw the next frame.

void

Called when the Renderer is destroyed.

void

Called when the RenderParameters has been updated.

final void

Posts a message to schedule a call to either CanvasRenderer.render or GlesRenderer.render to draw the next frame.

final void

Sends a request to the system asking it to update the preview image.

final void

Accessibility ContentDescriptionLabel for any rendered watch face elements other than the time and ComplicationSlots which are generated automatically.

final void
setInteractiveDrawModeUpdateDelayMillis(
    long interactiveDrawModeUpdateDelayMillis
)
final void

The SurfaceHolder that renderInternal will draw into.

final void

Representative WatchFaceColors which are made available to system clients via androidx.wear.watchface.client.InteractiveWatchFaceClient.OnWatchFaceColorsListener.

boolean

The system periodically (at least once per minute) calls onTimeTick() to trigger a display update.

From androidx.wear.watchface.Renderer.CanvasRenderer
final boolean

Whether the Canvas is cleared with RenderParameters.HighlightLayer.backgroundTint before renderHighlightLayer is called.

void

Called when adb shell dumpsys is invoked for the WatchFaceService, allowing the renderer to optionally record state for debugging purposes.

abstract void
@UiThread
render(
    @NonNull Canvas canvas,
    @NonNull Rect bounds,
    @NonNull ZonedDateTime zonedDateTime
)

Sub-classes should override this to implement their watch face rendering logic which should respect the current renderParameters.

abstract void
@UiThread
renderHighlightLayer(
    @NonNull Canvas canvas,
    @NonNull Rect bounds,
    @NonNull ZonedDateTime zonedDateTime
)

Sub-classes should override this to implement their watch face highlight layer rendering logic for the RenderParameters.highlightLayer aspect of renderParameters.

Public constructors

ListenableCanvasRenderer

Added in 1.1.0
Deprecated in 1.1.0
public ListenableCanvasRenderer(
    @NonNull SurfaceHolder surfaceHolder,
    @NonNull CurrentUserStyleRepository currentUserStyleRepository,
    @NonNull WatchState watchState,
    int canvasType,
    @IntRange(from = 0, to = 60000) long interactiveDrawModeUpdateDelayMillis,
    boolean clearWithBackgroundTintBeforeRenderingHighlightLayer
)

Public methods

init

Added in 1.0.0
Deprecated in 1.1.0
public void init()

Perform UiThread specific initialization. Will be called once during initialization before any subsequent calls to render. If you need to override this method in java, consider using androidx.wear.watchface.ListenableCanvasRenderer instead.

initFuture

Added in 1.0.0
Deprecated in 1.1.0
@UiThread
public @NonNull ListenableFuture<UnitinitFuture()

Perform UiThread specific initialization. Will be called once during initialization before any subsequent calls to render. Note cancellation of the returned future is not supported.

Returns
@NonNull ListenableFuture<Unit>

A ListenableFuture which is resolved when UiThread has completed. Rendering will be blocked until this has resolved.