diff --git a/app/src/main/java/xyz/immortalforest/widgets/widget/MediumWidget.kt b/app/src/main/java/xyz/immortalforest/widgets/widget/MediumWidget.kt index 15a597d..31c77b5 100644 --- a/app/src/main/java/xyz/immortalforest/widgets/widget/MediumWidget.kt +++ b/app/src/main/java/xyz/immortalforest/widgets/widget/MediumWidget.kt @@ -102,7 +102,9 @@ class MediumWidget : GlanceAppWidget() { .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), Bundle.EMPTY ) - loadImage(image.value.uri) + CoroutineScope(Dispatchers.IO).launch { + loadImage(context, id, image.value.uri) + } }, { context, id -> updateUI(context, id) @@ -127,15 +129,19 @@ class MediumWidget : GlanceAppWidget() { } private fun connectToSpotify() { + spotifyHelper.disconnect() spotifyHelper.connectToSpotify( onConnect = { context, id, appRemote -> spotifyAppRemote = appRemote updateUI(context, id) - listenToUpdates(context, id) + CoroutineScope(Dispatchers.IO).launch { + listenToUpdates(context, id) + } }, onError = { context, id -> paused.value = true updateUI(context, id) + connectToSpotify() }, ) diff --git a/app/src/main/java/xyz/immortalforest/widgets/widget/SmallWidget.kt b/app/src/main/java/xyz/immortalforest/widgets/widget/SmallWidget.kt index f78f6ff..3e628dc 100644 --- a/app/src/main/java/xyz/immortalforest/widgets/widget/SmallWidget.kt +++ b/app/src/main/java/xyz/immortalforest/widgets/widget/SmallWidget.kt @@ -96,7 +96,9 @@ class SmallWidget : GlanceAppWidget() { .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), Bundle.EMPTY ) - loadImage(image.value.uri) + CoroutineScope(Dispatchers.IO).launch { + loadImage(context, id, image.value.uri) + } }, { context, id -> updateUI(context, id) @@ -123,15 +125,19 @@ class SmallWidget : GlanceAppWidget() { } private fun connectToSpotify() { + spotifyHelper.disconnect() spotifyHelper.connectToSpotify( onConnect = { context, id, appRemote -> spotifyAppRemote = appRemote updateUI(context, id) - listenToUpdates(context, id) + CoroutineScope(Dispatchers.IO).launch { + listenToUpdates(context, id) + } }, onError = { context, id -> paused.value = true updateUI(context, id) + connectToSpotify() }, )