# TilesTimelineCache

# TilesTimelineCache

Artifact:[androidx.wear.tiles:tiles-renderer](https://developer.android.com/jetpack/androidx/releases/wear-tiles)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/timeline/TilesTimelineCache.java+class:androidx.wear.tiles.timeline.TilesTimelineCache)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/tiles/timeline/TilesTimelineCache "View this page in Java")

<br />

```
class TilesTimelineCache
```

<br />

*** ** * ** ***

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](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#TilesTimelineCache(androidx.wear.protolayout.TimelineBuilders.Timeline))`(timeline: `[TimelineBuilders.Timeline](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.Timeline)`)` Default constructor.                                                                                                                                                                                                                    |
| ~~[TilesTimelineCache](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#TilesTimelineCache(androidx.wear.tiles.TimelineBuilders.Timeline))~~`(timeline: `[TimelineBuilders.Timeline](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.Timeline)`)` **This function is deprecated.** Use[TilesTimelineCache](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#TilesTimelineCache(androidx.wear.protolayout.TimelineBuilders.Timeline))instead. <br /> |

|                                                             ### Public functions                                                             |
|----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.TimelineEntry)`?` | `@`[MainThread](https://developer.android.com/reference/kotlin/androidx/annotation/MainThread) [findClosestTileTimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findClosestTileTimelineEntry(long))`(timeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` A (very) inexact version of[findTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTimelineEntryForTime(long))which finds the closest timeline entry to the current time, regardless of validity.                                                                                                                                                                                                                                |
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.TimelineEntry)`?`       | `@`[MainThread](https://developer.android.com/reference/kotlin/androidx/annotation/MainThread) ~~[findClosestTimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findClosestTimelineEntry(long))~~`(timeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` **This function is deprecated.** Use[findClosestTileTimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findClosestTileTimelineEntry(long))instead. <br />                                                                                                                                                                                                                                                                                       |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                | `@`[MainThread](https://developer.android.com/reference/kotlin/androidx/annotation/MainThread) [findCurrentTimelineEntryExpiry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findCurrentTimelineEntryExpiry(androidx.wear.protolayout.TimelineBuilders.TimelineEntry,long))`(` ` entry: `[TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.TimelineEntry)`,` ` fromTimeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Finds when the timeline entry`entry`should be considered "expired".                                                                                                                                                                                                       |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                | `@`[MainThread](https://developer.android.com/reference/kotlin/androidx/annotation/MainThread) ~~[findCurrentTimelineEntryExpiry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findCurrentTimelineEntryExpiry(androidx.wear.tiles.TimelineBuilders.TimelineEntry,long))~~`(` ` entry: `[TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.TimelineEntry)`,` ` fromTimeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` **This function is deprecated.** Use[findCurrentTimelineEntryExpiry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findCurrentTimelineEntryExpiry(androidx.wear.protolayout.TimelineBuilders.TimelineEntry,long))instead. <br /> |
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.TimelineEntry)`?` | `@`[MainThread](https://developer.android.com/reference/kotlin/androidx/annotation/MainThread) [findTileTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTileTimelineEntryForTime(long))`(timeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Finds the entry which should be active at the given time.                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.TimelineEntry)`?`       | `@`[MainThread](https://developer.android.com/reference/kotlin/androidx/annotation/MainThread) ~~[findTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTimelineEntryForTime(long))~~`(timeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` **This function is deprecated.** Use[findTileTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTileTimelineEntryForTime(long))instead. <br />                                                                                                                                                                                                                                                                                       |

## Public constructors

### TilesTimelineCache

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
TilesTimelineCache(timeline: TimelineBuilders.Timeline)
```

Default constructor.  

### TilesTimelineCache

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)  
Deprecated in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
[TilesTimelineCache](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#TilesTimelineCache(androidx.wear.tiles.TimelineBuilders.Timeline))(timeline: TimelineBuilders.Timeline)
```
| **This function is deprecated.**   
|
| Use[TilesTimelineCache](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#TilesTimelineCache(androidx.wear.protolayout.TimelineBuilders.Timeline))instead.

Default constructor.  

## Public functions

### findClosestTileTimelineEntry

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
@MainThread
fun findClosestTileTimelineEntry(timeMillis: Long): TimelineBuilders.TimelineEntry?
```

A (very) inexact version of[findTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTimelineEntryForTime(long))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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time to search from, in milliseconds. |

|                                                                   Returns                                                                    |
|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.TimelineEntry)`?` | The timeline entry with validity period closest to`timeMillis`. |

### findClosestTimelineEntry

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)  
Deprecated in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
@MainThread
fun [findClosestTimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findClosestTimelineEntry(long))(timeMillis: Long): TimelineBuilders.TimelineEntry?
```
| **This function is deprecated.**   
|
| Use[findClosestTileTimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findClosestTileTimelineEntry(long))instead.

A (very) inexact version of[findTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTimelineEntryForTime(long))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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time to search from, in milliseconds. |

|                                                                Returns                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.TimelineEntry)`?` | The timeline entry with validity period closest to`timeMillis`. |

### findCurrentTimelineEntryExpiry

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
@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](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.TimelineEntry) | The entry to find the expiry time of.                                                               |
| `fromTimeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                    | The time to start searching from. The returned time will never be lower than the value passed here. |

|                                    Returns                                    |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time in millis that`entry`should be considered to be expired. This value will be[MAX_VALUE](https://developer.android.com/reference/java/lang/Long.html#MAX_VALUE())if`entry`does not expire. |

### findCurrentTimelineEntryExpiry

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)  
Deprecated in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
@MainThread
fun [findCurrentTimelineEntryExpiry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findCurrentTimelineEntryExpiry(androidx.wear.tiles.TimelineBuilders.TimelineEntry,long))(
    entry: TimelineBuilders.TimelineEntry,
    fromTimeMillis: Long
): Long
```
| **This function is deprecated.**   
|
| Use[findCurrentTimelineEntryExpiry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findCurrentTimelineEntryExpiry(androidx.wear.protolayout.TimelineBuilders.TimelineEntry,long))instead.

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](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.TimelineEntry) | The entry to find the expiry time of.                                                               |
| `fromTimeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                              | The time to start searching from. The returned time will never be lower than the value passed here. |

|                                    Returns                                    |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time in millis that`entry`should be considered to be expired. This value will be[MAX_VALUE](https://developer.android.com/reference/java/lang/Long.html#MAX_VALUE())if`entry`does not expire. |

### findTileTimelineEntryForTime

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
@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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time to base the search on, in milliseconds. |

|                                                                   Returns                                                                    |
|----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TimelineBuilders.TimelineEntry)`?` | The timeline entry which should be active at the given time. Returns`null`if none are valid. |

### findTimelineEntryForTime

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)  
Deprecated in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)  

```
@MainThread
fun [findTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTimelineEntryForTime(long))(timeMillis: Long): TimelineBuilders.TimelineEntry?
```
| **This function is deprecated.**   
|
| Use[findTileTimelineEntryForTime](https://developer.android.com/reference/kotlin/androidx/wear/tiles/timeline/TilesTimelineCache#findTileTimelineEntryForTime(long))instead.

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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The time to base the search on, in milliseconds. |

|                                                                Returns                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| [TimelineBuilders.TimelineEntry](https://developer.android.com/reference/kotlin/androidx/wear/tiles/TimelineBuilders.TimelineEntry)`?` | The timeline entry which should be active at the given time. Returns`null`if none are valid. |