CanvasComplicationFactory


interface CanvasComplicationFactory


Factory for creating a CanvasComplication. This decouples construction of Complications and their CanvasComplication renderers.

Summary

Public functions

CanvasComplication
@WorkerThread
create(
    watchState: WatchState,
    invalidateCallback: CanvasComplication.InvalidateCallback
)

Creates a CanvasComplication.

Public functions

create

Added in 1.0.0
@WorkerThread
fun create(
    watchState: WatchState,
    invalidateCallback: CanvasComplication.InvalidateCallback
): CanvasComplication

Creates a CanvasComplication. This will be called on a background thread, however all CanvasComplication rendering will be done on the UI thread and there's a memory barrier between construction and usage so no special threading primitives are required. If the CanvasComplication needs to share state with the Renderer then it should override onRendererCreated.

Parameters
watchState: WatchState

The current WatchState

invalidateCallback: CanvasComplication.InvalidateCallback

The CanvasComplication.InvalidateCallback the constructed CanvasComplication can use to request redrawing. This is typically used in conjunction with asynchronous loading of Drawables to update the watch face once the drawable has loaded.

Returns
CanvasComplication

The constructed CanvasComplication.