Added error popup when failed to download map

This commit is contained in:
Yair Morgenstern 2019-09-18 22:28:16 +03:00
parent f4d828d5e4
commit 753efe5f47
2 changed files with 7 additions and 1 deletions

View File

@ -114,6 +114,12 @@ class MapDownloadTable(mapEditorScreen: MapEditorScreen):PopupTable(mapEditorScr
val downloadMapButton = TextButton(downloadableMap.name, CameraStageBaseScreen.skin) val downloadMapButton = TextButton(downloadableMap.name, CameraStageBaseScreen.skin)
downloadMapButton.onClick { downloadMapButton.onClick {
val mapJsonGzipped = DropBox().downloadFile(downloadableMap.path_display) val mapJsonGzipped = DropBox().downloadFile(downloadableMap.path_display)
if(mapJsonGzipped==""){
val couldNotDownloadMapPopup = PopupTable(screen)
couldNotDownloadMapPopup.addGoodSizedLabel("Could not download map!").row()
couldNotDownloadMapPopup.addCloseButton()
return@onClick
}
val decodedMapJson = Gzip.unzip(mapJsonGzipped) val decodedMapJson = Gzip.unzip(mapJsonGzipped)
val mapObject = MapSaver().mapFromJson(decodedMapJson) val mapObject = MapSaver().mapFromJson(decodedMapJson)
MapSaver().saveMap(downloadableMap.name, mapObject) MapSaver().saveMap(downloadableMap.name, mapObject)

View File

@ -41,7 +41,7 @@ class DropBox(){
println(ex.message) println(ex.message)
val reader = BufferedReader(InputStreamReader(errorStream)) val reader = BufferedReader(InputStreamReader(errorStream))
println(reader.readText()) println(reader.readText())
return "Error!" return ""
} }
} }
} }