ComplicationText

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 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 methods

getNextChangeTime

@NonNull
public abstract Instant getNextChangeTime(@NonNull Instant afterInstant)

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

getTextAt

@NonNull
public abstract 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

@NonNull
public abstract boolean isAlwaysEmpty()

returnsSameText

@NonNull
public 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.