public interface ComplicationText


The text within a complication.

This text may change over time and this interface provides both a way to determine the current text to show with getTextAt but also a way to know whether the text needs to be re-rendered, by means of returnsSameText, getNextChangeTime, and isAlwaysEmpty.

Summary

Public fields

default static final @NonNull ComplicationText
default static final @NonNull ComplicationText

For use when the real data isn't available yet, this ComplicationText should be rendered as a placeholder.

Public methods

abstract @NonNull Instant

Returns the next time after afterInstant at which the text may change.

abstract @NonNull CharSequence
getTextAt(@NonNull Resources resources, @NonNull Instant instant)

Returns the text that should be displayed for the given timestamp.

abstract boolean
abstract boolean
returnsSameText(
    @NonNull Instant firstInstant,
    @NonNull Instant secondInstant
)

Returns true if the result of getTextAt will be the same for both firstInstant and secondInstant.

Public fields

EMPTY

default static final @NonNull ComplicationText EMPTY

PLACEHOLDER

default static final @NonNull ComplicationText PLACEHOLDER

For use when the real data isn't available yet, this ComplicationText should be rendered as a placeholder. It is suggested that it should be rendered with a light grey box.

Note a placeholder may only be used in the context of NoDataComplicationData.placeholder.

Public methods

getNextChangeTime

Added in 1.0.0
abstract @NonNull Instant getNextChangeTime(@NonNull Instant afterInstant)

Returns the next time after afterInstant at which the text may change.

getTextAt

Added in 1.0.0
abstract @NonNull CharSequence getTextAt(@NonNull Resources resources, @NonNull Instant instant)

Returns the text that should be displayed for the given timestamp.

Parameters
@NonNull Resources resources

Resources from the current context

@NonNull Instant instant

The Instant at which to sample the text

isAlwaysEmpty

Added in 1.0.0
abstract boolean isAlwaysEmpty()

returnsSameText

Added in 1.0.0
abstract boolean returnsSameText(
    @NonNull Instant firstInstant,
    @NonNull Instant secondInstant
)

Returns true if the result of getTextAt will be the same for both firstInstant and secondInstant.