smmdb api auery is now in it's own thread

* smmdb api auery is now in it's own thread
* fixed a issue where cemu_UI freezed on a 502 http error of the smmdb api
* jfoenix 1.10 -> 1.11
* sqlite 3.20.0. -> sqlite 3.20.0.1
This commit is contained in:
Jannik 2017-12-09 13:10:19 +01:00
parent 548629eeaf
commit 75d8e6b525
4 changed files with 43 additions and 24 deletions

View File

@ -28,7 +28,7 @@
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>1.10.0</version>
<version>1.11.1</version>
</dependency>
<dependency>
@ -40,7 +40,7 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0</version>
<version>3.21.0.1</version>
</dependency>
<dependency>

View File

@ -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<CourseTableDataType>(helpCourse)); // add data to root-node
}
Platform.runLater(() -> {
root.getChildren().add(new TreeItem<CourseTableDataType>(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();

View File

@ -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 + "}";

View File

@ -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