All UI changes in MultiplayerScreen now use postRunnable to run on the main thread

This commit is contained in:
Yair Morgenstern 2020-06-27 23:51:05 +03:00
parent cba9995f99
commit 1bb26c579d

View File

@ -135,9 +135,9 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
return
}
thread(name="MultiplayerDownload") {
addGameButton.setText("Working...".tr())
addGameButton.disable()
thread(name="MultiplayerDownload") {
try {
// The tryDownload can take more than 500ms. Therefore, to avoid ANRs,
// we need to run it in a different thread.
@ -157,10 +157,12 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
errorPopup.open()
}
}
Gdx.app.postRunnable {
addGameButton.setText(addGameText)
addGameButton.enable()
}
}
}
//just loads the game from savefile
//the game will be downloaded opon joining it anyway
@ -256,12 +258,15 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
} catch (ex: Exception) {
//skipping one is not fatal
//Trying to use as many prev. used strings as possible
Gdx.app.postRunnable {
ResponsePopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this)
}
continue
}
}
//Reset UI
Gdx.app.postRunnable {
addGameButton.enable()
refreshButton.setText(refreshText)
refreshButton.enable()
@ -269,6 +274,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
reloadGameListUI()
}
}
}
//Adds a Button to add the currently running game to multiplayerGameList
private fun addCurrentGameButton(){