TilesTimelineCache
class TilesTimelineCache
Timeline cache for Wear Tiles. This will take in a full timeline, and return the appropriate entry for the given time from findTimelineEntryForTime
.
Summary
Public constructors |
---|
TilesTimelineCache(timeline: TimelineBuilders.Timeline) Default constructor. |
This function is deprecated. Use |
Public constructors
TilesTimelineCache
TilesTimelineCache(timeline: TimelineBuilders.Timeline)
Default constructor.
Public functions
findClosestTileTimelineEntry
@MainThread
fun findClosestTileTimelineEntry(timeMillis: Long): TimelineBuilders.TimelineEntry?
A (very) inexact version of findTimelineEntryForTime
which finds the closest timeline entry to the current time, regardless of validity. This should only used as a fallback if findTimelineEntryForTime
fails, so it can attempt to at least show something.
By this point, we're technically in an error state, so just show _something_. Note that calling this if findTimelineEntryForTime
returns a valid entry is invalid, and may lead to incorrect results.
Parameters | |
---|---|
timeMillis: Long |
The time to search from, in milliseconds. |
Returns | |
---|---|
TimelineBuilders.TimelineEntry? |
The timeline entry with validity period closest to |
@MainThread
funfindClosestTimelineEntry(timeMillis: Long): TimelineBuilders.TimelineEntry?
A (very) inexact version of findTimelineEntryForTime
which finds the closest timeline entry to the current time, regardless of validity. This should only used as a fallback if findTimelineEntryForTime
fails, so it can attempt to at least show something.
By this point, we're technically in an error state, so just show _something_. Note that calling this if findTimelineEntryForTime
returns a valid entry is invalid, and may lead to incorrect results.
Parameters | |
---|---|
timeMillis: Long |
The time to search from, in milliseconds. |
Returns | |
---|---|
TimelineBuilders.TimelineEntry? |
The timeline entry with validity period closest to |
findCurrentTimelineEntryExpiry
@MainThread
fun findCurrentTimelineEntryExpiry(
entry: TimelineBuilders.TimelineEntry,
fromTimeMillis: Long
): Long
Finds when the timeline entry entry
should be considered "expired". This is either when it is no longer valid (i.e. end_millis), or when another entry should be presented instead.
Parameters | |
---|---|
entry: TimelineBuilders.TimelineEntry |
The entry to find the expiry time of. |
fromTimeMillis: Long |
The time to start searching from. The returned time will never be lower than the value passed here. |
@MainThread
funfindCurrentTimelineEntryExpiry(
entry: TimelineBuilders.TimelineEntry,
fromTimeMillis: Long
): Long
Finds when the timeline entry entry
should be considered "expired". This is either when it is no longer valid (i.e. end_millis), or when another entry should be presented instead.
Parameters | |
---|---|
entry: TimelineBuilders.TimelineEntry |
The entry to find the expiry time of. |
fromTimeMillis: Long |
The time to start searching from. The returned time will never be lower than the value passed here. |
findTileTimelineEntryForTime
@MainThread
fun findTileTimelineEntryForTime(timeMillis: Long): TimelineBuilders.TimelineEntry?
Finds the entry which should be active at the given time. This will return the entry which has the _shortest_ validity period at the current time, if validity periods overlap. Note that an entry which has no validity period set will be considered a "default" and will be used if no other entries are suitable.
Parameters | |
---|---|
timeMillis: Long |
The time to base the search on, in milliseconds. |
Returns | |
---|---|
TimelineBuilders.TimelineEntry? |
The timeline entry which should be active at the given time. Returns |
@MainThread
funfindTimelineEntryForTime(timeMillis: Long): TimelineBuilders.TimelineEntry?
Finds the entry which should be active at the given time. This will return the entry which has the _shortest_ validity period at the current time, if validity periods overlap. Note that an entry which has no validity period set will be considered a "default" and will be used if no other entries are suitable.
Parameters | |
---|---|
timeMillis: Long |
The time to base the search on, in milliseconds. |
Returns | |
---|---|
TimelineBuilders.TimelineEntry? |
The timeline entry which should be active at the given time. Returns |