CanvasComplicationDrawable


open class CanvasComplicationDrawable : CanvasComplication


A complication rendered with ComplicationDrawable which renders complicationSlots in a material design style. This renderer can't be shared by multiple complicationSlots.

Summary

Public constructors

CanvasComplicationDrawable(
    drawable: ComplicationDrawable,
    watchState: WatchState,
    invalidateCallback: CanvasComplication.InvalidateCallback
)

Public functions

open Unit
drawHighlight(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int
)

Draws a highlight for a ComplicationSlotBoundsType.ROUND_RECT complication.

open ComplicationData

Returns the ComplicationData to render with.

open Unit
@CallSuper
loadData(
    complicationData: ComplicationData,
    loadDrawablesAsynchronous: Boolean
)

Updates the ComplicationData used for rendering and loads any Drawables within the complicationData.

open Unit
render(
    canvas: Canvas,
    bounds: Rect,
    zonedDateTime: ZonedDateTime,
    renderParameters: RenderParameters,
    slotId: Int
)

Draws the complication defined by getData into the canvas with the specified bounds.

Public properties

ComplicationDrawable

The ComplicationDrawable to render with.

Inherited functions

From androidx.wear.watchface.CanvasComplication
open Unit
@ComplicationExperimental
drawHighlight(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int,
    boundingArc: BoundingArc?
)

Draws a highlight for a ComplicationSlotBoundsType.ROUND_RECT complication.

open Unit

Called once on a background thread before any subsequent UI thread rendering to inform the CanvasComplication of the Renderer which is useful if they need to share state.

Public constructors

CanvasComplicationDrawable

Added in 1.0.0
CanvasComplicationDrawable(
    drawable: ComplicationDrawable,
    watchState: WatchState,
    invalidateCallback: CanvasComplication.InvalidateCallback
)
Parameters
drawable: ComplicationDrawable

The ComplicationDrawable to render with.

watchState: WatchState

The watch's WatchState which contains details pertaining to (low-bit) ambient mode and burn in protection needed to render correctly.

invalidateCallback: CanvasComplication.InvalidateCallback

The CanvasComplication.InvalidateCallback associated with which can be used to request screen redrawing and to report updates

Public functions

drawHighlight

Added in 1.0.0
open fun drawHighlight(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int
): Unit

Draws a highlight for a ComplicationSlotBoundsType.ROUND_RECT complication. The default implementation does this by drawing a dashed line around the complication, other visual effects may be used if desired.

Parameters
canvas: Canvas

The Canvas to render into

bounds: Rect

A Rect describing the bounds of the complication

boundsType: Int

The ComplicationSlotBoundsTypeIntDef of the complication

zonedDateTime: ZonedDateTime

The ZonedDateTime to render the highlight with

color: @ColorInt Int

The color to render the highlight with

getData

Added in 1.0.0
open fun getData(): ComplicationData

Returns the ComplicationData to render with. This defaults to NoDataComplicationData.

loadData

Added in 1.0.0
@CallSuper
open fun loadData(
    complicationData: ComplicationData,
    loadDrawablesAsynchronous: Boolean
): Unit

Updates the ComplicationData used for rendering and loads any Drawables within the complicationData.

Parameters
complicationData: ComplicationData

The new ComplicationData for which any Drawables should be loaded

loadDrawablesAsynchronous: Boolean

Whether any Drawables within complicationData should be loaded asynchronously or not. If they are loaded asynchronously then upon completion, ComplicationDrawable.setComplicationData will call Drawable.Callback.invalidateDrawable registered in our init section above, which invalidates the attachedComplication and ultimately the watch face.

render

Added in 1.0.0
open fun render(
    canvas: Canvas,
    bounds: Rect,
    zonedDateTime: ZonedDateTime,
    renderParameters: RenderParameters,
    slotId: Int
): Unit

Draws the complication defined by getData into the canvas with the specified bounds. This will usually be called by user watch face drawing code, but the system may also call it for complication selection UI rendering. The width and height will be the same as that computed by computeBounds but the translation and canvas size may differ.

Parameters
canvas: Canvas

The Canvas to render into

bounds: Rect

A Rect describing the bounds of the complication

zonedDateTime: ZonedDateTime

The ZonedDateTime to render with

renderParameters: RenderParameters

The current RenderParameters

slotId: Int

The Id of the ComplicationSlot being rendered

Public properties

drawable

Added in 1.0.0
var drawableComplicationDrawable

The ComplicationDrawable to render with.