Skip to content

Commit

Permalink
Merge pull request #11 from Seil0/dev
Browse files Browse the repository at this point in the history
update to build 127 "plasma cow"
  • Loading branch information
Seil0 authored Jun 1, 2017
2 parents 6baa47b + e53d1d1 commit 08048d5
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="src/libraries/minimal-json-0.9.4.jar"/>
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.16.1.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.3.0.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-io-2.5.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.4.0.jar"/>
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.18.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@


Project HomeFlix is a Kellerkinder Project, that alowes you to sort all your local saved movies in clean UI.
The dev branch is **only merged** into master when a **new release** is released. Please commit all changes to [dev](https://github.com/Seil0/Project-HomeFlix/tree/dev).
The dev branch is **only merged** into master when a **new release** is released, so **master contains the latest released version**. Please commit all changes to [dev](https://github.com/Seil0/Project-HomeFlix/tree/dev).

Librarys used in this Project:
JFoenix: https://github.com/jfoenixadmin/JFoenix
minimal-json: https://github.com/ralfstx/minimal-json
sqlite-jdbc: https://github.com/xerial/sqlite-jdbc
sqlite-jdbc: https://github.com/xerial/sqlite-jdbc
apache commons io : https://commons.apache.org/proper/commons-io/

## Installation

Expand Down
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/application/
/libraries/
Binary file modified bin/application/DBController.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$1.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$2.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$3.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$4.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$5.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$6.class
Binary file not shown.
Binary file modified bin/application/MainWindowController$7.class
Binary file not shown.
Binary file modified bin/application/MainWindowController.class
Binary file not shown.
Binary file modified bin/application/updater.class
Binary file not shown.
Binary file not shown.
Binary file removed bin/libraries/sqlite-jdbc-3.16.1.jar
Binary file not shown.
Binary file added bin/libraries/sqlite-jdbc-3.18.0.jar
Binary file not shown.
23 changes: 9 additions & 14 deletions src/application/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.Thread.State;
import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -184,10 +183,8 @@ public class MainWindowController {
static boolean firststart = false;
private int hashA = -2055934614;
private String version = "0.5.1";
private String buildNumber = "125";
private String buildNumber = "127";
private String versionName = "plasma cow";
private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt";
private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt";
private File dirWin = new File(System.getProperty("user.home") + "/Documents/HomeFlix");
private File dirLinux = new File(System.getProperty("user.home") + "/HomeFlix");
private File fileWin = new File(dirWin + "/config.xml");
Expand Down Expand Up @@ -470,13 +467,9 @@ private void mainColorAction(){

@FXML
private void updateBtnAction(){
System.out.println(Updater.getState());
if(Updater.getState() == State.NEW){
Updater.start();
}else{
Updater.run();
}

Thread updateThread = new Thread(Updater);
updateThread.setName("Updater");
updateThread.start();
}

@FXML
Expand Down Expand Up @@ -519,7 +512,7 @@ private void streamingDirectoryBtnAction(){
*/
void setMain(Main main) {
this.main = main;
Updater = new updater(this,buildURL, downloadLink, buildNumber);
Updater = new updater(this, buildNumber);
dbController = new DBController(this, this.main);
ApiQuery = new apiQuery(this, dbController, this.main);
}
Expand Down Expand Up @@ -763,8 +756,10 @@ void initUI(){
if(autoUpdate){
autoupdateBtn.setSelected(true);
try {
Updater.start();
Updater.join();
Thread updateThread = new Thread(Updater);
updateThread.setName("Updater");
updateThread.start();
updateThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
Expand Down
50 changes: 35 additions & 15 deletions src/application/updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@

import org.apache.commons.io.FileUtils;

import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonValue;

import javafx.application.Platform;

public class updater extends Thread{
public class updater implements Runnable{

private MainWindowController mainWindowController;
private String buildURL;
private String downloadLink;
private String updateBuildNumber;
private String buildNumber;
private String apiOutput;
private String updateBuildNumber; //tag_name from Github
private String browserDownloadUrl; //update download link
private String githubApi = "https://api.github.com/repos/Seil0/Project-HomeFlix/releases/latest";


public updater(MainWindowController m, String buildURL,String downloadLink,String buildNumber){
public updater(MainWindowController m, String buildNumber){
mainWindowController=m;
this.buildURL=buildURL;
this.downloadLink=downloadLink;
this.buildNumber=buildNumber;
}

Expand All @@ -37,14 +42,27 @@ public void run(){
Platform.runLater(() -> {
mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("checkingUpdates"));
});
try {
URL url = new URL(buildURL); //URL of the text file with the current build number
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
updateBuildNumber = in.readLine(); //write InputStream in String
in.close();

try {
URL githubApiUrl = new URL(githubApi);
BufferedReader ina = new BufferedReader(new InputStreamReader(githubApiUrl.openStream()));
apiOutput = ina.readLine();
ina.close();
} catch (IOException e1) {
mainWindowController.showErrorMsg(mainWindowController.errorUpdateV, e1);
e1.printStackTrace();
}

JsonObject object = Json.parse(apiOutput).asObject();
JsonArray objectAssets = Json.parse(apiOutput).asObject().get("assets").asArray();

updateBuildNumber = object.getString("tag_name", "");
// updateName = object.getString("name", "");
// updateChanges = object.getString("body", "");
for (JsonValue asset : objectAssets) {
browserDownloadUrl = asset.asObject().getString("browser_download_url", "");

}
System.out.println("Build: "+buildNumber+", Update: "+updateBuildNumber);

//Compares the program BuildNumber with the current BuildNumber if program BuildNumber < current BuildNumber then perform a update
Expand All @@ -61,9 +79,10 @@ public void run(){
mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnavail"));
});
System.out.println("update available");
System.out.println("download link: " + browserDownloadUrl);
try {
//get the download-Data URL
URL downloadURL = new URL(downloadLink);
URL downloadURL = new URL(browserDownloadUrl);
BufferedReader in = new BufferedReader(new InputStreamReader(downloadURL.openStream()));
String updateDataURL = in.readLine();

Expand All @@ -80,8 +99,9 @@ public void run(){
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again
System.exit(0); //finishes itself
} catch (IOException e) {
//in case there is an error
mainWindowController.showErrorMsg(mainWindowController.errorUpdateD, e);
Platform.runLater(() -> {
mainWindowController.showErrorMsg(mainWindowController.errorUpdateD, e);
});
}
}
}
Expand Down
Binary file not shown.
Binary file removed src/libraries/sqlite-jdbc-3.16.1.jar
Binary file not shown.
Binary file added src/libraries/sqlite-jdbc-3.18.0.jar
Binary file not shown.

0 comments on commit 08048d5

Please sign in to comment.