Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplayer Notification Fix for random Termination #2024

Merged
merged 5 commits into from
Feb 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Optimization
  • Loading branch information
wrov committed Feb 27, 2020
commit e08f2b5790924b54eebe067bc1cfa7f27dd476fe
8 changes: 4 additions & 4 deletions android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
enqueue(applicationContext, inputData.getInt(CONFIGURED_DELAY, 5), inputDataFailReset)
}
} catch (ex: Exception) {
if (inputData.getInt(FAIL_COUNT, 0) > 3) {
val failCount = inputData.getInt(FAIL_COUNT, 0)
if (failCount > 3) {
showErrorNotification()
with(NotificationManagerCompat.from(applicationContext)) {
cancel(NOTIFICATION_ID_SERVICE)
Expand All @@ -226,9 +227,8 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
// If check fails, retry in one minute.
// Makes sense, since checks only happen if Internet is available in principle.
// Therefore a failure means either a problem with the GameInfo or with Dropbox.
val newErrorCount = inputData.getInt(FAIL_COUNT, 0) + 1
val inputDataFailReset = Data.Builder().putAll(inputData).putInt(FAIL_COUNT, newErrorCount).build()
enqueue(applicationContext, 1, inputDataFailReset)
val inputDataFailIncrease = Data.Builder().putAll(inputData).putInt(FAIL_COUNT, failCount + 1).build()
enqueue(applicationContext, 1, inputDataFailIncrease)
// Persistent Notification is not updated, because user may think check succeed.
}
}
Expand Down