fix some crashes

This commit is contained in:
Phillip Thelen 2023-05-25 15:12:13 +02:00
parent 66c1e9ee00
commit 13f82e686d
5 changed files with 25 additions and 14 deletions

View file

@ -135,6 +135,7 @@ class PurchaseHandler(
}
}
private var listeningRetryCount = 0
fun startListening() {
if (billingClient.connectionState == BillingClient.ConnectionState.CONNECTING ||
billingClient.connectionState == BillingClient.ConnectionState.CONNECTED ||
@ -143,6 +144,10 @@ class PurchaseHandler(
// Don't connect again if it's already connected
return
}
if (listeningRetryCount > 10) {
// Something is wrong
return
}
billingClientState = BillingClientState.CONNECTING
billingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult : BillingResult) {
@ -152,13 +157,9 @@ class PurchaseHandler(
queryPurchases()
}
} else if (billingResult.responseCode == BillingClient.BillingResponseCode.SERVICE_DISCONNECTED) {
startListening()
retryListening()
} else if (billingResult.responseCode == BillingClient.BillingResponseCode.SERVICE_TIMEOUT) {
CoroutineScope(Dispatchers.IO).launchCatching {
// try again after 30 seconds
delay(30.seconds)
startListening()
}
retryListening()
} else {
billingClientState = BillingClientState.UNAVAILABLE
}
@ -166,11 +167,20 @@ class PurchaseHandler(
override fun onBillingServiceDisconnected() {
billingClientState = BillingClientState.DISCONNECTED
startListening()
retryListening()
}
})
}
private fun retryListening() {
listeningRetryCount += 1
CoroutineScope(Dispatchers.IO).launchCatching {
// try again after 30 seconds
delay(30.seconds)
startListening()
}
}
fun stopListening() {
billingClient.endConnection()
}

View file

@ -230,7 +230,7 @@ fun PartyInviteView(
modifier = Modifier
.onFocusChanged {
if (!it.isFocused) {
if (viewModel.invites[index].isBlank() && viewModel.invites.size - 1 != index && viewModel.invites.size > 1) {
if (viewModel.invites.size > index && viewModel.invites[index].isBlank() && viewModel.invites.size - 1 != index && viewModel.invites.size > 1) {
viewModel.invites.removeAt(index)
}
}

View file

@ -111,9 +111,10 @@ class AuthenticationViewModel @Inject constructor(
// Unable to authenticate, such as when the user has not yet granted
// the app access to the account, but the user can fix this.
// Forward the user to an activity in Google Play services.
val intent = e.intent
recoverFromPlayServicesErrorResult.launch(intent)
return
if (!activity.isFinishing) {
val intent = e.intent
recoverFromPlayServicesErrorResult.launch(intent)
}
}
}

View file

@ -1,4 +1,4 @@
New in 4.2:
New in 4.2.1:
It's easier than ever to party up with our newest feature: Look for Party and Find Members!
- Solo players can let Party leaders know they want an invite by going to Menu > Party and tapping 'Look for Party'

View file

@ -1,2 +1,2 @@
NAME=4.2
CODE=6071
NAME=4.2.1
CODE=6101