Bug Fix for Multiplayer Screen (#1970)

* Possible Bug Fix 

Testing if clipboard content == null
This should have been a problem before

* Moved null check into addMultiplayerGame

making it more readable
This commit is contained in:
GGGuenni 2020-02-19 13:31:46 +01:00 committed by GitHub
parent cf84f5a0b5
commit 8733f02f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,14 +111,11 @@ class MultiplayerScreen() : PickerScreen() {
} }
//Adds a new Multiplayer game to the List //Adds a new Multiplayer game to the List
fun addMultiplayerGame(gameId: String, gameName: String = ""){ //gameId must be nullable because clipboard content could be null
if (gameIsAlreadySavedAsMultiplayer(gameId)) { fun addMultiplayerGame(gameId: String?, gameName: String = ""){
ResponsePopup("Game is already added".tr(), this)
return
}
try { try {
//since the gameId is a String it can contain anything and has to be checked //since the gameId is a String it can contain anything and has to be checked
UUID.fromString(gameId.trim()) UUID.fromString(gameId!!.trim())
} catch (ex: Exception) { } catch (ex: Exception) {
val errorPopup = Popup(this) val errorPopup = Popup(this)
errorPopup.addGoodSizedLabel("Invalid game ID!".tr()) errorPopup.addGoodSizedLabel("Invalid game ID!".tr())
@ -127,6 +124,12 @@ class MultiplayerScreen() : PickerScreen() {
errorPopup.open() errorPopup.open()
return return
} }
if (gameIsAlreadySavedAsMultiplayer(gameId)) {
ResponsePopup("Game is already added".tr(), this)
return
}
thread(name="MultiplayerDownload") { thread(name="MultiplayerDownload") {
addGameButton.setText("Working...".tr()) addGameButton.setText("Working...".tr())
addGameButton.disable() addGameButton.disable()