DynamicComplicationText


@RequiresApi(value = 33)
public final class DynamicComplicationText implements ComplicationText


A ComplicationText where the system evaluates a DynamicString. By the time this reaches the watch face's Renderer, it'll have been converted to a plain ComplicationText.

Summary

Public constructors

Creates a DynamicComplicationText with no fallbackValue for API levels that are known to support dynamic values.

DynamicComplicationText(
    @NonNull DynamicBuilders.DynamicString dynamicValue,
    @NonNull CharSequence fallbackValue
)

Public methods

boolean
equals(Object other)
final @NonNull DynamicBuilders.DynamicString

The DynamicString which will be evaluated into a value dynamically.

final @NonNull CharSequence

Used when the system does not support dynamicValue.

@NonNull Instant

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

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

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

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

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

@NonNull String

Public constructors

DynamicComplicationText

Added in 1.3.0-alpha04
@RequiresApi(value = 34)
public DynamicComplicationText(
    @NonNull DynamicBuilders.DynamicString dynamicValue
)

Creates a DynamicComplicationText with no fallbackValue for API levels that are known to support dynamic values.

DynamicComplicationText

Added in 1.2.0
public DynamicComplicationText(
    @NonNull DynamicBuilders.DynamicString dynamicValue,
    @NonNull CharSequence fallbackValue
)
Parameters
@NonNull DynamicBuilders.DynamicString dynamicValue

The DynamicString which will be evaluated into a value dynamically.

@NonNull CharSequence fallbackValue

Used when the system does not support dynamicValue.

This is only relevant before Build.VERSION_CODES.UPSIDE_DOWN_CAKE, use the no-fallback constructor if you target an equal or higher API level.

IMPORTANT: This is only used when the system does not support dynamicValue at all. See ComplicationData.dynamicValueInvalidationFallback for the situation where the dynamicValue cannot be evaluated, e.g. when a data source is not available.

Public methods

equals

public boolean equals(Object other)

getDynamicValue

Added in 1.2.0
public final @NonNull DynamicBuilders.DynamicString getDynamicValue()

The DynamicString which will be evaluated into a value dynamically.

getFallbackValue

Added in 1.2.0
public final @NonNull CharSequence getFallbackValue()

Used when the system does not support dynamicValue.

This is only relevant before Build.VERSION_CODES.UPSIDE_DOWN_CAKE, use the no-fallback constructor if you target an equal or higher API level.

IMPORTANT: This is only used when the system does not support dynamicValue at all. See ComplicationData.dynamicValueInvalidationFallback for the situation where the dynamicValue cannot be evaluated, e.g. when a data source is not available.

getNextChangeTime

Added in 1.3.0-alpha04
public @NonNull Instant getNextChangeTime(@NonNull Instant afterInstant)

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

getTextAt

Added in 1.3.0-alpha04
public @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

hashCode

public int hashCode()

isAlwaysEmpty

Added in 1.3.0-alpha04
public boolean isAlwaysEmpty()

returnsSameText

Added in 1.3.0-alpha04
public boolean returnsSameText(
    @NonNull Instant firstInstant,
    @NonNull Instant secondInstant
)

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

toString

public @NonNull String toString()