CanvasComplication
interface CanvasComplication
androidx.wear.watchface.CanvasComplication |
Interface for rendering complications onto a Canvas.
Summary
Public methods | |
---|---|
abstract Unit |
onAttach(complication: Complication) Called when the CanvasComplication attaches to a Complication. |
abstract Unit |
onDetach() Called when the CanvasComplication detaches from a Complication. |
abstract Unit |
render(canvas: Canvas, bounds: Rect, calendar: Calendar, renderParameters: RenderParameters) Draws the complication defined by idAndData into the canvas with the specified bounds. |
abstract Unit |
setIdComplicationDataSync(idAndComplicationData: IdAndComplicationData?) |
Properties | |
---|---|
abstract IdAndComplicationData? |
The IdAndComplicationData to render. |
abstract Boolean |
Whether the complication should be drawn highlighted. |
Public methods
onAttach
@UiThread abstract fun onAttach(complication: Complication): Unit
Called when the CanvasComplication attaches to a Complication. This will get called during Complication initialization and if Complication.renderer is assigned with this CanvasComplication.
onDetach
@UiThread abstract fun onDetach(): Unit
Called when the CanvasComplication detaches from a Complication. This will get called if Complication.renderer is assigned to a different CanvasComplication.
render
@UiThread abstract fun render(
canvas: Canvas,
bounds: Rect,
calendar: Calendar,
renderParameters: RenderParameters
): Unit
Draws the complication defined by idAndData 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 |
calendar: Calendar | The current Calendar |
renderParameters: RenderParameters | The current RenderParameters |
setIdComplicationDataSync
abstract fun setIdComplicationDataSync(idAndComplicationData: IdAndComplicationData?): Unit
Properties
isHighlighted
abstract var isHighlighted: Boolean
Whether the complication should be drawn highlighted. This is to provide visual feedback when the user taps on a complication.