From 99b774393443be831a2906188c53af48315f52e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20V=C3=A9lez=20Palacios?= Date: Sat, 21 May 2016 19:59:41 +0200 Subject: [PATCH] small bugfix + elegant thing --- .../estraba/controller/SplashController.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/es/kauron/estraba/controller/SplashController.java b/src/main/java/es/kauron/estraba/controller/SplashController.java index 82b0cb4..814fe0e 100644 --- a/src/main/java/es/kauron/estraba/controller/SplashController.java +++ b/src/main/java/es/kauron/estraba/controller/SplashController.java @@ -65,32 +65,31 @@ public class SplashController implements Initializable{ return; } - Task t = new Task() { + Thread th = new Thread(new Task() { @Override protected DataBundle call() throws Exception { DataBundle db = DataBundle.loadFrom(file); - System.out.println("done"); - updateProgress(1, 1); return db; } - }; - t.setOnSucceeded(ev -> { - DataBundle bundle = t.getValue(); - if (bundle == null) errorLoading(); - FXMLLoader loader = new FXMLLoader( - App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE); - Parent parent = null; - try { - parent = loader.load(); - } catch (IOException e) { - errorLoading(); + @Override + protected void succeeded() { + super.succeeded(); + DataBundle bundle = getValue(); + if (bundle == null) errorLoading(); + FXMLLoader loader = new FXMLLoader( + App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE); + Parent parent = null; + try { + parent = loader.load(); + loader.getController().postInit(bundle); + ((Stage) root.getScene().getWindow()).setScene(new Scene(parent)); + } catch (IOException e) { + errorLoading(); + } } - loader.getController().postInit(bundle); - ((Stage) root.getScene().getWindow()).setScene(new Scene(parent)); }); - Thread th = new Thread(t); th.setDaemon(true); th.start();