Updated library

This commit is contained in:
Gabriel Tofvesson 2016-11-13 15:00:20 +01:00
parent 34984083ce
commit ac052812b2
3 changed files with 27 additions and 17 deletions

Binary file not shown.

View File

@ -10,6 +10,7 @@ favour and pour yourself some nice Jack Daniels. You deserve it if you're going
package Launcher; package Launcher;
import Launcher.net.Updater;
import com.tofvesson.reflection.SafeReflection; import com.tofvesson.reflection.SafeReflection;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
@ -147,7 +148,11 @@ public class Main extends Application {
icon.setImage(appIcon); icon.setImage(appIcon);
} }
public static void main(String[] args) { launch(args); } public static void main(String[] args) {
Updater u = Updater.getInstance();
launch(args);
}
/** /**
* Search for packs with an 80% match compared to detected string. * Search for packs with an 80% match compared to detected string.

View File

@ -1,6 +1,10 @@
package Launcher.net; package Launcher.net;
import com.tofvesson.async.Async;
import com.tofvesson.reflection.SafeReflection;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
@ -9,27 +13,28 @@ import java.net.URLConnection;
*/ */
public class Updater { public class Updater {
private static Updater instance; private static volatile Updater instance;
private static final Async<Updater> setup = new Async<>(SafeReflection.getFirstConstructor(Updater.class));
private URLConnection conn; private URLConnection conn;
public static final URL updateURL;
private boolean isUpdateAvailable = false;
private Updater(String URL) throws IOException { static {
conn = new URL(URL).openConnection(); URL u = null;
try { u = new URL("https://github.com/GabrielTofvesson/TeamAvionLauncher/releases/"); } catch (MalformedURLException e) { e.printStackTrace(); }
updateURL = u;
} }
public void downloadStuff(){ private Updater(){
//TODO: try {
} conn = updateURL.openConnection();
public void downloadMoreStuff(){ } catch (IOException e) {
System.out.println("No internet connection available!");
} }
}
public void downloadEvenMoreStuff(){
public static Updater getInstance() {
} return instance==null?instance=setup.await():instance; // Await async creation
public static Updater getInstance(String url) throws IOException {
if(instance==null) instance = new Updater(url);
return instance;
} }
} }