Slide 11
Slide 11 text
Implementing a Tile feature
class MainTileService : CoroutinesTileService() {
// Abbreviates some procedures, such as reading data from the repository
override suspend fun resourcesRequest(
requestParams: RequestBuilders.ResourcesRequest
): ResourceBuilders.Resources {
return ResourceBuilders.Resources.Builder().setVersion(RESOURCES_VERSION).build()
}
override suspend fun tileRequest(
requestParams: RequestBuilders.TileRequest
): TileBuilders.Tile {
val singleTileTimeline = TimelineBuilders.Timeline.Builder().addTimelineEntry(
TimelineBuilders.TimelineEntry.Builder().setLayout(
LayoutElementBuilders.Layout.Builder().setRoot(tileLayout(this)).build()
).build()
).build()
return TileBuilders.Tile.Builder().setResourcesVersion(RESOURCES_VERSION)
.setTimeline(singleTileTimeline).build()
}
}
a Kotlin coroutine-friendly wrapper
from the Horologist Tiles library
/MainTileService.kt