mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 23:08:35 +07:00
Fix coroutines not being added to desktop:dist (#6822)
* Use kotlin coroutines instead of raw threads (+ refactorings)
Equal to f8e0f572
* Fix coroutine class files not being added to desktop:dist
This commit is contained in:
@ -20,7 +20,9 @@ android {
|
||||
}
|
||||
}
|
||||
packagingOptions {
|
||||
resources.excludes.add("META-INF/robovm/ios/robovm.xml")
|
||||
resources.excludes += "META-INF/robovm/ios/robovm.xml"
|
||||
// part of kotlinx-coroutines-android, should not go into the apk
|
||||
resources.excludes += "DebugProbesKt.bin"
|
||||
}
|
||||
defaultConfig {
|
||||
applicationId = "com.unciv.app"
|
||||
|
@ -15,9 +15,10 @@ import androidx.work.*
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.logic.multiplayer.FileStorageRateLimitReached
|
||||
import com.unciv.logic.multiplayer.storage.FileStorageRateLimitReached
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
import com.unciv.logic.multiplayer.OnlineMultiplayer
|
||||
import com.unciv.logic.multiplayer.storage.OnlineMultiplayerGameSaver
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
@ -234,7 +235,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
}
|
||||
}
|
||||
|
||||
override fun doWork(): Result {
|
||||
override fun doWork(): Result = runBlocking {
|
||||
val showPersistNotific = inputData.getBoolean(PERSISTENT_NOTIFICATION_ENABLED, true)
|
||||
val configuredDelay = inputData.getInt(CONFIGURED_DELAY, 5)
|
||||
val fileStorage = inputData.getString(FILE_STORAGE)
|
||||
@ -253,7 +254,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
continue
|
||||
|
||||
try {
|
||||
val gamePreview = OnlineMultiplayer(fileStorage).tryDownloadGamePreview(gameId)
|
||||
val gamePreview = OnlineMultiplayerGameSaver(fileStorage).tryDownloadGamePreview(gameId)
|
||||
val currentTurnPlayer = gamePreview.getCivilization(gamePreview.currentPlayer)
|
||||
|
||||
//Save game so MultiplayerScreen gets updated
|
||||
@ -302,7 +303,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
with(NotificationManagerCompat.from(applicationContext)) {
|
||||
cancel(NOTIFICATION_ID_SERVICE)
|
||||
}
|
||||
return Result.failure()
|
||||
return@runBlocking Result.failure()
|
||||
} else {
|
||||
if (showPersistNotific) { showPersistentNotification(applicationContext,
|
||||
applicationContext.resources.getString(R.string.Notify_Error_Retrying), configuredDelay.toString()) }
|
||||
@ -313,9 +314,9 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
enqueue(applicationContext, 1, inputDataFailIncrease)
|
||||
}
|
||||
} catch (outOfMemory: OutOfMemoryError){ // no point in trying multiple times if this was an oom error
|
||||
return Result.failure()
|
||||
return@runBlocking Result.failure()
|
||||
}
|
||||
return Result.success()
|
||||
return@runBlocking Result.success()
|
||||
}
|
||||
|
||||
private fun getStackTraceString(ex: Exception): String {
|
||||
|
Reference in New Issue
Block a user