diff --git a/pom.xml b/pom.xml index 3ea9e73..3a37a6d 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ com.jfoenix jfoenix - 1.10.0 + 1.11.1 @@ -40,7 +40,7 @@ org.xerial sqlite-jdbc - 3.21.0 + 3.21.0.1 diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index ebfcc12..719c4a1 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -787,17 +787,32 @@ public class MainWindowController { smmdbAnchorPane.setVisible(true); smmdbTrue = true; - // start query - courses.removeAll(courses); - courses.addAll(smmdbAPIController.startQuery()); + // start query in new thread + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + Platform.runLater(() -> { + smmdbDownloadBtn.setText("loading ..."); + smmdbDownloadBtn.setDisable(true); + root.getChildren().remove(0,root.getChildren().size()); + }); + courses.removeAll(courses); // remove existing courses + courses.addAll(smmdbAPIController.startQuery()); // start query - // add query response to courseTreeTable - for (int i = 0; i < courses.size(); i++) { - CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), - courses.get(i).getId(), courses.get(i).getTime(), courses.get(i).getStars()); + // add query response to courseTreeTable + for (int i = 0; i < courses.size(); i++) { + CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), + courses.get(i).getId(), courses.get(i).getTime(), courses.get(i).getStars()); - root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node - } + Platform.runLater(() -> { + root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node + smmdbDownloadBtn.setText("Download"); + smmdbDownloadBtn.setDisable(false); + }); + } + } + }); + thread.start(); } } @@ -880,6 +895,7 @@ public class MainWindowController { String outputFile = getCemuPath() + "/"; try { + LOGGER.info("beginning download ..."); HttpURLConnection conn = (HttpURLConnection) new URL(downloadUrl).openConnection(); ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", conn.getInputStream()); ProgressMonitor pm = pmis.getProgressMonitor(); @@ -914,22 +930,23 @@ public class MainWindowController { String number = "000" + (highestCourseNumber +1); courseName = "course" + number.substring(number.length() -3, number.length()); - File courseDirectory = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i) + "/"); - + File courseDirectory = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i) + "/"); destination = courseDirectory.getPath(); - } + } } - try { - ZipFile zipFile = new ZipFile(source); - zipFile.extractAll(destination); - - // rename zip-file - File course = new File(destination + "/course000"); - course.renameTo( new File(destination + "/" + courseName)); - LOGGER.info("Added new course: " + courseName + ", full path is: " + destination + "/" + courseName); - } catch (ZipException e) { - LOGGER.error("an error occurred during unziping the file!", e); + if (destination != null) { + try { + ZipFile zipFile = new ZipFile(source); + zipFile.extractAll(destination); + + // rename zip-file + File course = new File(destination + "/course000"); + course.renameTo( new File(destination + "/" + courseName)); + LOGGER.info("Added new course: " + courseName + ", full path is: " + destination + "/" + courseName); + } catch (ZipException e) { + LOGGER.error("an error occurred during unziping the file!", e); + } } downloadFile.delete(); diff --git a/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java b/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java index 6ded4e7..bf14b95 100644 --- a/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java +++ b/src/main/java/com/cemu_UI/controller/SmmdbAPIController.java @@ -63,6 +63,7 @@ public class SmmdbAPIController { } catch (IOException e) { LOGGER.error("error while making api request or reading response"); LOGGER.error("response from " + URL + " was: " + output, e); + return course; } String apiOutput = "{ \"courses\": " + output + "}"; diff --git a/src/main/java/com/cemu_UI/controller/dbController.java b/src/main/java/com/cemu_UI/controller/dbController.java index 2818032..be4facf 100644 --- a/src/main/java/com/cemu_UI/controller/dbController.java +++ b/src/main/java/com/cemu_UI/controller/dbController.java @@ -115,6 +115,7 @@ public class dbController { LOGGER.info("games database loaded successfull"); } + /** * creating the local_roms table in localRoms.db * if the table has no entries, call loadRomDirectory