fixed first startup issue

This commit is contained in:
Jannik 2018-10-11 12:29:26 +02:00
parent a1319382ff
commit a23b87fcb8
2 changed files with 31 additions and 3 deletions

View File

@ -108,9 +108,12 @@ public class Main extends Application {
primaryStage.setScene(scene); // append scene to stage primaryStage.setScene(scene); // append scene to stage
primaryStage.show(); // show stage primaryStage.show(); // show stage
System.out.println("test");
// startup checks TODO move to mwc // startup checks TODO move to mwc
if (!configFile.exists()) { if (!configFile.exists()) {
directory.mkdir(); directory.mkdir();
System.out.println("config not found");
addFirstSource(); addFirstSource();
mainWindowController.setColor("ee3523"); mainWindowController.setColor("ee3523");
@ -123,6 +126,8 @@ public class Main extends Application {
if (!posterCache.exists()) { if (!posterCache.exists()) {
posterCache.mkdir(); posterCache.mkdir();
} }
mainWindowController.init();
} catch (IOException e) { } catch (IOException e) {
LOGGER.error(e); LOGGER.error(e);
} }
@ -156,7 +161,7 @@ public class Main extends Application {
* we need to get the path for the first source from the user and add it to * we need to get the path for the first source from the user and add it to
* sources.json, if the user ends the file-/directory-chooser the program will exit * sources.json, if the user ends the file-/directory-chooser the program will exit
*/ */
private void addFirstSource() { void addFirstSource() {
switch (local) { switch (local) {
case "en_US": case "en_US":
bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english
@ -208,6 +213,7 @@ public class Main extends Application {
} }
} }
}; };
selectFirstSource.setBtn1Action(btn1Action); selectFirstSource.setBtn1Action(btn1Action);
selectFirstSource.setBtn2Action(btn2Action); selectFirstSource.setBtn2Action(btn2Action);
selectFirstSource.showAndWait(); selectFirstSource.showAndWait();

View File

@ -200,9 +200,11 @@ public class MainWindowController {
dbController = new DBController(this.main, this); dbController = new DBController(this.main, this);
} }
@FXML
public void initialize() { public void init() {
LOGGER.info("Initializing Project-HomeFlix build " + buildNumber); LOGGER.info("Initializing Project-HomeFlix build " + buildNumber);
// startupCheck();
main.loadSettings(); // load settings main.loadSettings(); // load settings
checkAutoUpdate(); checkAutoUpdate();
@ -215,6 +217,26 @@ public class MainWindowController {
checkAllPosters(); // TODO testing checkAllPosters(); // TODO testing
} }
private void startupCheck() {
if (!main.getConfigFile().exists()) {
main.getDirectory().mkdir();
System.out.println("config not found");
main.addFirstSource(); // need to get local
System.out.println("source finished");
mainWindowController.setColor("ee3523");
mainWindowController.setFontSize(17.0);
mainWindowController.setAutoUpdate(false);
mainWindowController.setLocal(local); // local dosen't exist here
main.saveSettings();
}
if (!main.getPosterCache().exists()) {
main.getPosterCache().mkdir();
}
}
// Initialize general UI elements // Initialize general UI elements
private void initUI() { private void initUI() {
versionLbl.setText("Version: " + version + " (Build: " + buildNumber + ")"); versionLbl.setText("Version: " + version + " (Build: " + buildNumber + ")");