ComplicationSlotsManager


class ComplicationSlotsManager


The ComplicationSlots associated with the WatchFace. Dynamic creation of ComplicationSlots isn't supported, however complicationSlots can be enabled and disabled by ComplicationSlotsUserStyleSetting.

Summary

Nested types

Interface used to report user taps on the ComplicationSlot.

Public constructors

ComplicationSlotsManager(
    complicationSlotCollection: Collection<ComplicationSlot>,
    currentUserStyleRepository: CurrentUserStyleRepository
)

Public functions

Unit

Adds a TapCallback which is called whenever the user interacts with a complication slot.

open operator Boolean
equals(other: Any?)
operator ComplicationSlot?
get(id: Int)

Returns the ComplicationSlot corresponding to id, if there is one, or null.

ComplicationSlot?

Returns the background ComplicationSlot if there is one or null otherwise.

ComplicationSlot?

Returns the id of the complication slot at coordinates x, y or null if there isn't one.

open Int
Unit

Removes a TapCallback previously added by addTapListener.

Public properties

Map<IntComplicationSlot>

A map of complication IDs to complicationSlots.

Map<IntTapEvent>

Map of ComplicationSlot id to the latest TapType.DOWN that the ComplicationSlot received, if any.

Public constructors

ComplicationSlotsManager

Added in 1.0.0
ComplicationSlotsManager(
    complicationSlotCollection: Collection<ComplicationSlot>,
    currentUserStyleRepository: CurrentUserStyleRepository
)
Parameters
complicationSlotCollection: Collection<ComplicationSlot>

The ComplicationSlots associated with the watch face, may be empty.

currentUserStyleRepository: CurrentUserStyleRepository

The CurrentUserStyleRepository used to listen for ComplicationSlotsUserStyleSetting changes and apply them.

Public functions

addTapListener

Added in 1.0.0
@UiThread
fun addTapListener(tapCallback: ComplicationSlotsManager.TapCallback): Unit

Adds a TapCallback which is called whenever the user interacts with a complication slot.

equals

open operator fun equals(other: Any?): Boolean

get

Added in 1.0.0
operator fun get(id: Int): ComplicationSlot?

Returns the ComplicationSlot corresponding to id, if there is one, or null.

getBackgroundComplicationSlot

Added in 1.0.0
fun getBackgroundComplicationSlot(): ComplicationSlot?

Returns the background ComplicationSlot if there is one or null otherwise.

Returns
ComplicationSlot?

The background ComplicationSlot if there is one or null otherwise

getComplicationSlotAt

Added in 1.0.0
fun getComplicationSlotAt(x: @Px Int, y: @Px Int): ComplicationSlot?

Returns the id of the complication slot at coordinates x, y or null if there isn't one. Initially checks slots without margins (should be no overlaps) then then if there was no hit it tries again this time with margins (overlaps are possible) reporting the first hit if any.

Parameters
x: @Px Int

The x coordinate of the point to perform a hit test

y: @Px Int

The y coordinate of the point to perform a hit test

Returns
ComplicationSlot?

The ComplicationSlot at coordinates x, y or {@code null} if there isn't one

hashCode

open fun hashCode(): Int

removeTapListener

Added in 1.0.0
@UiThread
fun removeTapListener(tapCallback: ComplicationSlotsManager.TapCallback): Unit

Removes a TapCallback previously added by addTapListener.

Public properties

complicationSlots

Added in 1.0.0
val complicationSlotsMap<IntComplicationSlot>

A map of complication IDs to complicationSlots.

lastComplicationTapDownEvents

Added in 1.0.0
val lastComplicationTapDownEventsMap<IntTapEvent>

Map of ComplicationSlot id to the latest TapType.DOWN that the ComplicationSlot received, if any.