From 19217707dcd1e2fc3d4e519d0713af41435ca78b Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Thu, 7 Jul 2022 11:44:04 +0200 Subject: [PATCH] Fix crash --- .../habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt index d6ba0758b..0f87a1f1c 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt @@ -44,6 +44,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job +import kotlinx.coroutines.MainScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch @@ -308,7 +309,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop if (shopItem.isValid && !shopItem.locked) { val gemsLeft = if (shopItem.limitedNumberLeft != null) shopItem.limitedNumberLeft else 0 if ((gemsLeft == 0 && shopItem.purchaseType == "gems") || shopItem.canAfford(user, purchaseQuantity)) { - GlobalScope.launch { + MainScope().launch(Dispatchers.Main) { remainingPurchaseQuantity { quantity -> if (quantity >= 0) { if (quantity < purchaseQuantity) {