CanvasComplicationFactory

public interface CanvasComplicationFactory


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

Summary

Public methods

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

Creates a CanvasComplication.

Public methods

create

Added in 1.0.0
@WorkerThread
abstract @NonNull CanvasComplication create(
    @NonNull WatchState watchState,
    @NonNull CanvasComplication.InvalidateCallback invalidateCallback
)

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
@NonNull WatchState watchState

The current WatchState

@NonNull CanvasComplication.InvalidateCallback 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
@NonNull CanvasComplication

The constructed CanvasComplication.