mirror of
https://github.com/home-assistant/android
synced 2024-07-03 08:08:35 +00:00
Update shortcut tile add/remove + destroy handling (#3974)
- Updates the shortcut tile's handling of add/remove event + destroying the service, just like the camera tile, to prevent the service scope being cancelled while the app is still storing tile added/removed - (this service already didn't overwrite existing tile data when onTileAddEvent was called again)
This commit is contained in:
parent
d143da9ea3
commit
73c928d6e4
|
@ -42,7 +42,8 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.guava.future
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.nio.ByteBuffer
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.min
|
||||
|
@ -146,8 +147,8 @@ class ShortcutsTile : TileService() {
|
|||
.build()
|
||||
}
|
||||
|
||||
override fun onTileAddEvent(requestParams: EventBuilders.TileAddEvent) {
|
||||
serviceScope.launch {
|
||||
override fun onTileAddEvent(requestParams: EventBuilders.TileAddEvent): Unit = runBlocking {
|
||||
withContext(Dispatchers.IO) {
|
||||
/**
|
||||
* When the app is updated from an older version (which only supported a single Shortcut Tile),
|
||||
* and the user is adding a new Shortcuts Tile, we can't tell for sure if it's the 1st or 2nd Tile.
|
||||
|
@ -167,8 +168,8 @@ class ShortcutsTile : TileService() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onTileRemoveEvent(requestParams: EventBuilders.TileRemoveEvent) {
|
||||
serviceScope.launch {
|
||||
override fun onTileRemoveEvent(requestParams: EventBuilders.TileRemoveEvent): Unit = runBlocking {
|
||||
withContext(Dispatchers.IO) {
|
||||
wearPrefsRepository.removeTileShortcuts(requestParams.tileId)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user