Browse Source

fixed first startup issue

pull/12/head
Jannik 3 years ago
parent
commit
a23b87fcb8
2 changed files with 31 additions and 3 deletions
  1. +7
    -1
      src/main/java/kellerkinder/HomeFlix/application/Main.java
  2. +24
    -2
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java

+ 7
- 1
src/main/java/kellerkinder/HomeFlix/application/Main.java View File

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


+ 24
- 2
src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java View File

@ -200,9 +200,11 @@ public class MainWindowController {
dbController = new DBController(this.main, this);
}
@FXML
public void initialize() {
public void init() {
LOGGER.info("Initializing Project-HomeFlix build " + buildNumber);
// startupCheck();
main.loadSettings(); // load settings
checkAutoUpdate();
@ -215,6 +217,26 @@ public class MainWindowController {
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
private void initUI() {
versionLbl.setText("Version: " + version + " (Build: " + buildNumber + ")");


Loading…
Cancel
Save