HomeFlix supports more than one source directory
* HomeFlix supports more than one source directory, this is WIP! * general code cleanup
This commit is contained in:
		| @ -12,7 +12,7 @@ | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
| 	</classpathentry> | ||||
| 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9"> | ||||
| 	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||||
| 		<attributes> | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
| @ -22,10 +22,6 @@ | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
| 	</classpathentry> | ||||
| 	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||||
| 		<attributes> | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
| 	</classpathentry> | ||||
| 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||||
| 	<classpathentry kind="output" path="target/classes"/> | ||||
| </classpath> | ||||
|  | ||||
| @ -107,8 +107,7 @@ public class Main extends Application { | ||||
| 			// startup checks | ||||
| 			if (!configFile.exists()) { | ||||
| 				directory.mkdir(); | ||||
| 				mainWindowController.setPath(firstStart()); | ||||
| 				mainWindowController.setStreamingPath(directory.getAbsolutePath()); | ||||
| 				mainWindowController.addSource(firstStart(), "local"); | ||||
| 				mainWindowController.setColor("ee3523"); | ||||
| 				mainWindowController.setSize(FONT_SIZE); | ||||
| 				mainWindowController.setAutoUpdate(false); | ||||
| @ -143,14 +142,17 @@ public class Main extends Application { | ||||
| 	 | ||||
| 	// Method for first Start | ||||
| 	private String firstStart(){ | ||||
| 		switch(System.getProperty("user.language")+"_"+System.getProperty("user.country")){ | ||||
| 		case "en_US":	bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US);	//us_english | ||||
| 				break; | ||||
|      	case "de_DE":	bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.GERMAN);	//German | ||||
|      			break; | ||||
|      	default:		bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US);	//default local | ||||
|      			break; | ||||
| 		 } | ||||
| 		switch (System.getProperty("user.language") + "_" + System.getProperty("user.country")) { | ||||
| 		case "en_US": | ||||
| 			bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english | ||||
| 			break; | ||||
| 		case "de_DE": | ||||
| 			bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.GERMAN); // German | ||||
| 			break; | ||||
| 		default: | ||||
| 			bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // default local | ||||
| 			break; | ||||
| 		} | ||||
| 		 | ||||
| 		Alert alert = new Alert(AlertType.CONFIRMATION);	//new alert with file-chooser | ||||
| 		alert.setTitle("Project HomeFlix"); | ||||
|  | ||||
| @ -27,12 +27,15 @@ import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | ||||
| import java.io.FileReader; | ||||
| import java.io.FileWriter; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | ||||
| import java.io.OutputStream; | ||||
| import java.io.PrintWriter; | ||||
| import java.io.StringWriter; | ||||
| import java.io.Writer; | ||||
| import java.math.BigInteger; | ||||
| import java.net.URI; | ||||
| import java.net.URISyntaxException; | ||||
| @ -46,6 +49,9 @@ import org.apache.logging.log4j.LogManager; | ||||
| import org.apache.logging.log4j.Logger; | ||||
|  | ||||
| import com.cemu_UI.uiElements.JFXInfoDialog; | ||||
| import com.eclipsesource.json.Json; | ||||
| import com.eclipsesource.json.JsonArray; | ||||
| import com.eclipsesource.json.JsonObject; | ||||
| import com.jfoenix.controls.JFXButton; | ||||
| import com.jfoenix.controls.JFXColorPicker; | ||||
| import com.jfoenix.controls.JFXHamburger; | ||||
| @ -54,8 +60,6 @@ import com.jfoenix.controls.JFXTextField; | ||||
| import com.jfoenix.controls.JFXToggleButton; | ||||
| import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; | ||||
|  | ||||
| import javafx.animation.FadeTransition; | ||||
| import javafx.animation.ParallelTransition; | ||||
| import javafx.animation.TranslateTransition; | ||||
| import javafx.beans.value.ChangeListener; | ||||
| import javafx.beans.value.ObservableValue; | ||||
| @ -90,6 +94,7 @@ import javafx.scene.paint.Color; | ||||
| import javafx.scene.text.Font; | ||||
| import javafx.scene.text.TextFlow; | ||||
| import javafx.stage.DirectoryChooser; | ||||
| import javafx.stage.FileChooser; | ||||
| import javafx.util.Duration; | ||||
| import kellerkinder.HomeFlix.controller.DBController; | ||||
| import kellerkinder.HomeFlix.controller.UpdateController; | ||||
| @ -101,9 +106,6 @@ public class MainWindowController { | ||||
| 	@FXML | ||||
| 	private AnchorPane mainAnchorPane; | ||||
| 	 | ||||
| 	@FXML  | ||||
| 	private AnchorPane streamingSettingsAnchorPane; | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private ScrollPane settingsScrollPane; | ||||
| 	 | ||||
| @ -120,8 +122,8 @@ public class MainWindowController { | ||||
| 	private TreeTableView<tableData> treeTableViewfilm; | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private TableView<tableData> tableViewStreamingdata; | ||||
| 	 | ||||
| 	private TableView<tableData> sourcesTable; | ||||
|  | ||||
| 	@FXML | ||||
| 	private TextFlow textFlow; | ||||
|  | ||||
| @ -143,9 +145,6 @@ public class MainWindowController { | ||||
|     @FXML | ||||
|     private JFXButton settingsBtn; | ||||
|      | ||||
|     @FXML | ||||
|     private JFXButton streamingSettingsBtn; | ||||
|      | ||||
|     @FXML | ||||
|     private JFXButton switchBtn; | ||||
|      | ||||
| @ -156,10 +155,10 @@ public class MainWindowController { | ||||
|     public JFXButton updateBtn; | ||||
|      | ||||
|     @FXML | ||||
|     private JFXButton directoryBtn; | ||||
|     private JFXButton addDirectoryBtn; | ||||
|      | ||||
|     @FXML | ||||
|     private JFXButton streamingDirectoryBtn; | ||||
|     private JFXButton addStreamSourceBtn; | ||||
|      | ||||
|     @FXML | ||||
|     private JFXHamburger menuHam; | ||||
| @ -167,12 +166,6 @@ public class MainWindowController { | ||||
|     @FXML | ||||
|     private JFXToggleButton autoUpdateToggleBtn; | ||||
|      | ||||
|     @FXML | ||||
|     public JFXTextField filmDirTextField; | ||||
|      | ||||
|     @FXML | ||||
|     public JFXTextField streamingPathTextField; | ||||
|      | ||||
|     @FXML | ||||
|     private JFXTextField searchTextField; | ||||
|      | ||||
| @ -191,9 +184,6 @@ public class MainWindowController { | ||||
|     @FXML | ||||
|     private Label homeflixSettingsLbl; | ||||
| 	 | ||||
|     @FXML | ||||
|     private Label filmDirectoryLbl; | ||||
| 	 | ||||
|     @FXML | ||||
|     private Label mainColorLbl; | ||||
| 	 | ||||
| @ -208,6 +198,9 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private Label branchLbl; | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private Label sourcesLbl; | ||||
|  | ||||
| 	@FXML | ||||
| 	private Label versionLbl; | ||||
| @ -218,7 +211,7 @@ public class MainWindowController { | ||||
|     private ImageView imv1; | ||||
|      | ||||
| 	@FXML | ||||
| 	TreeItem<tableData> root = new TreeItem<>(new tableData(1, 1, 1, 5.0, "1", "filme", "1", imv1, false)); | ||||
| 	public TreeItem<tableData> root = new TreeItem<>(new tableData(1, 1, 1, 5.0, "1", "filme", "1", imv1, false)); | ||||
| 	@FXML | ||||
| 	TreeTableColumn<tableData, ImageView> columnRating = new TreeTableColumn<>("Rating"); | ||||
| 	@FXML | ||||
| @ -235,15 +228,14 @@ public class MainWindowController { | ||||
| 	TreeTableColumn<tableData, Integer> columnEpisode = new TreeTableColumn<>("Episode"); | ||||
|      | ||||
|     @FXML | ||||
|     private TreeItem<tableData> streamingRoot =new TreeItem<>(new tableData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1", imv1, false)); | ||||
|     public TreeItem<tableData> streamingRoot =new TreeItem<>(new tableData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1", imv1, false)); // TODO make private | ||||
|     @FXML | ||||
|     private TableColumn<tableData, String> dataNameColumn = new TableColumn<>("Datei Name"); | ||||
|     private TableColumn<tableData, String> sourceColumn; | ||||
|     @FXML | ||||
|     private TableColumn<tableData, String> dataNameEndColumn = new TableColumn<>("Datei Name mit Endung"); | ||||
|     private TableColumn<tableData, String> modeColumn; | ||||
| 	 | ||||
| 	private boolean menuTrue = false; | ||||
| 	private boolean settingsTrue = false; | ||||
| 	private boolean streamingSettingsTrue = false; | ||||
| 	private boolean autoUpdate = false; | ||||
| 	private boolean useBeta = false; | ||||
|     private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName()); | ||||
| @ -262,7 +254,6 @@ public class MainWindowController { | ||||
| 	private String errorSave; | ||||
| 	private String infoText; | ||||
| 	private String vlcNotInstalled; | ||||
| 	private String path; | ||||
| 	private String streamingPath; | ||||
| 	private String color; | ||||
| 	private String name; | ||||
| @ -275,8 +266,6 @@ public class MainWindowController { | ||||
| 	private int last; | ||||
| 	private int selected; | ||||
| 	private int next; | ||||
| 	private File selectedFolder; | ||||
| 	private File selectedStreamingFolder; | ||||
| 	private ResourceBundle bundle; | ||||
|  | ||||
| 	private ObservableList<tableData> filterData = FXCollections.observableArrayList(); | ||||
| @ -284,7 +273,7 @@ public class MainWindowController { | ||||
| 	private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta"); | ||||
| 	private ObservableList<tableData> localFilms = FXCollections.observableArrayList(); | ||||
| 	private ObservableList<tableData> streamingFilms = FXCollections.observableArrayList(); | ||||
| 	private ObservableList<tableData> streamingData = FXCollections.observableArrayList(); | ||||
| 	private ObservableList<tableData> sourcesList = FXCollections.observableArrayList(); | ||||
| 	private ImageView skip_previous_white = new ImageView(new Image("icons/ic_skip_previous_white_18dp_1x.png")); | ||||
| 	private ImageView skip_previous_black = new ImageView(new Image("icons/ic_skip_previous_black_18dp_1x.png")); | ||||
| 	private ImageView skip_next_white = new ImageView(new Image("icons/ic_skip_next_white_18dp_1x.png")); | ||||
| @ -313,11 +302,10 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	void init() { | ||||
| 		loadSettings(); | ||||
| 		loadStreamingSettings(); | ||||
| 		checkAutoUpdate(); | ||||
| 		initTabel(); | ||||
| 		initActions(); | ||||
| 		initUI();	 | ||||
| 		initUI(); | ||||
| 	} | ||||
| 	 | ||||
| 	//Initialize the tables (treeTableViewfilm and tableViewStreamingdata) | ||||
| @ -327,8 +315,6 @@ public class MainWindowController { | ||||
| 	    columnRating.setMaxWidth(80); | ||||
| 	    columnTitel.setMaxWidth(260); | ||||
| 	    columnStreamUrl.setMaxWidth(0); | ||||
| 	    dataNameColumn.setPrefWidth(150); | ||||
| 	    dataNameEndColumn.setPrefWidth(220); | ||||
| 	    columnRating.setStyle("-fx-alignment: CENTER;"); | ||||
| 		 | ||||
|         treeTableViewfilm.setRoot(root); | ||||
| @ -353,119 +339,80 @@ public class MainWindowController { | ||||
|         treeTableViewfilm.getColumns().add(columnSeason); | ||||
|         treeTableViewfilm.getColumns().add(columnEpisode); | ||||
|         treeTableViewfilm.getColumns().get(2).setVisible(false); //hide columnStreamUrl (column with file URL, important for opening a file/stream) | ||||
| 	 | ||||
| 	    //Change-listener for treeTableViewfilm | ||||
| 	    treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {	 | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){ | ||||
| 				// last = selected; //for auto-play | ||||
| 				selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); //get selected item | ||||
| 				last = selected - 1; | ||||
| 				next = selected + 1; | ||||
| 				name = columnTitel.getCellData(selected); //get name of selected item | ||||
| 				datPath = columnStreamUrl.getCellData(selected); //get file path of selected item | ||||
| 				 | ||||
| 				if(mode.equals("local")){ | ||||
| 					if(localFilms.get(selected).getCached()==true){ | ||||
| 						LOGGER.info("loading from cache: "+name); | ||||
| 						dbController.readCache(datPath); | ||||
| 					}else{ | ||||
| 						ApiQuery.startQuery(name,datPath); // start api query | ||||
| 					} | ||||
| 				}else{ | ||||
| 					LOGGER.info(streamingFilms.size()); | ||||
| 					if(streamingFilms.get(selected).getCached()==true){ | ||||
| 						LOGGER.info("loading from cache: "+name); | ||||
| 						dbController.readCache(datPath); | ||||
| 					}else{ | ||||
| 						ApiQuery.startQuery(name,datPath); // start api query | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
| 	     | ||||
| 	    //context menu for treeTableViewfilm   | ||||
| 	    treeTableViewfilm.setContextMenu(menu); | ||||
|  | ||||
| 	    //Streaming-Settings Table | ||||
| 	    dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty()); | ||||
| 	    dataNameEndColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty()); | ||||
| 		 | ||||
| 	    tableViewStreamingdata.getColumns().add(dataNameColumn); | ||||
| 	    tableViewStreamingdata.getColumns().add(dataNameEndColumn); | ||||
| 	    tableViewStreamingdata.setItems(streamingData);  | ||||
| 	     | ||||
| 	    // sourcesTreeTable | ||||
| 	    sourceColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty()); | ||||
| 	    modeColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty()); | ||||
| 	    sourcesTable.setItems(sourcesList); | ||||
| 	} | ||||
| 	 | ||||
| 	//Initializing the actions | ||||
| 	private void initActions(){ | ||||
| 		 | ||||
| 	private void initActions() { | ||||
|  | ||||
| 		HamburgerBackArrowBasicTransition burgerTask = new HamburgerBackArrowBasicTransition(menuHam); | ||||
| 		menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e)->{ | ||||
| 	    	if(menuTrue == false){ | ||||
| 		menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> { | ||||
| 			if (menuTrue == false) { | ||||
| 				sideMenuSlideIn(); | ||||
| 				burgerTask.setRate(1.0); | ||||
| 				burgerTask.play(); | ||||
| 				menuTrue = true; | ||||
| 			}else{ | ||||
| 			} else { | ||||
| 				sideMenuSlideOut(); | ||||
| 				burgerTask.setRate(-1.0); | ||||
| 				burgerTask.play(); | ||||
| 				menuTrue = false; | ||||
| 			} | ||||
| 			if(settingsTrue == true){ | ||||
| 			if (settingsTrue == true) { | ||||
| 				settingsScrollPane.setVisible(false); | ||||
| 				setPath(filmDirTextField.getText()); | ||||
| 				saveSettings(); | ||||
| 				settingsTrue = false; | ||||
| 			} | ||||
| 			if(streamingSettingsTrue == true){ | ||||
| 				streamingSettingsAnchorPane.setVisible(false); | ||||
| 				streamingSettingsTrue = false; | ||||
| 			} | ||||
| 			 | ||||
| 		}); | ||||
| 		 | ||||
|  | ||||
| 		searchTextField.textProperty().addListener(new ChangeListener<String>() { | ||||
|     	    @Override | ||||
|     	    public void changed(ObservableValue<? extends String> observable,String oldValue, String newValue) { | ||||
|             	ObservableList<tableData> helpData; | ||||
|     	    	filterData.removeAll(filterData); | ||||
|     	    	root.getChildren().remove(0,root.getChildren().size()); | ||||
|     	    	 | ||||
|   	    		if(mode.equals("local")){ | ||||
|   	            	helpData = localFilms; | ||||
|   	    		}else{ | ||||
|   	    			helpData = streamingFilms; | ||||
|   	    		} | ||||
|     	    	 | ||||
|     	    	for(int i = 0; i < helpData.size(); i++){ | ||||
|     	    		if(helpData.get(i).getTitle().toLowerCase().contains(searchTextField.getText().toLowerCase())){ | ||||
|     	    			filterData.add(helpData.get(i));	//add data from newDaten to filteredData where title contains search input | ||||
|     	    		} | ||||
|     	    	} | ||||
|     	    	 | ||||
|     	    	for(int i = 0; i < filterData.size(); i++){ | ||||
|     				root.getChildren().add(new TreeItem<tableData>(filterData.get(i)));	//add filtered data to root node after search | ||||
|     			} | ||||
|     	    	if(searchTextField.getText().hashCode()== hashA){ | ||||
|     	    		setColor("000000"); | ||||
|     	    		applyColor(); | ||||
|     	    	} | ||||
|     	    } | ||||
|     	}); | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { | ||||
| 				ObservableList<tableData> helpData; | ||||
| 				filterData.removeAll(filterData); | ||||
| 				root.getChildren().remove(0, root.getChildren().size()); | ||||
|  | ||||
| 				if (mode.equals("local")) { | ||||
| 					helpData = localFilms; | ||||
| 				} else { | ||||
| 					helpData = streamingFilms; | ||||
| 				} | ||||
|  | ||||
| 				for (int i = 0; i < helpData.size(); i++) { | ||||
| 					if (helpData.get(i).getTitle().toLowerCase().contains(searchTextField.getText().toLowerCase())) { | ||||
| 						filterData.add(helpData.get(i)); // add data from newDaten to filteredData where title contains search input | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				for (int i = 0; i < filterData.size(); i++) { | ||||
| 					root.getChildren().add(new TreeItem<tableData>(filterData.get(i))); // add filtered data to root node after search | ||||
| 				} | ||||
| 				if (searchTextField.getText().hashCode() == hashA) { | ||||
| 					setColor("000000"); | ||||
| 					applyColor(); | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
|          | ||||
|         languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { | ||||
|           @Override | ||||
| 		public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) { | ||||
|         	  String local = languageChoisBox.getItems().get((int) new_value).toString(); | ||||
|         	  local = local.substring(local.length()-6,local.length()-1);	//reading only en_US from English (en_US) | ||||
|         	  setLocal(local); | ||||
|         	  setLocalUI(); | ||||
|         	  saveSettings(); | ||||
|           } | ||||
|         }); | ||||
|          | ||||
|         branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { | ||||
| 		languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) { | ||||
| 				String local = languageChoisBox.getItems().get((int) new_value).toString(); | ||||
| 				local = local.substring(local.length() - 6, local.length() - 1); // reading only en_US from English (en_US) | ||||
| 				setLocal(local); | ||||
| 				setLocalUI(); | ||||
| 				saveSettings(); | ||||
| 			} | ||||
| 		}); | ||||
|  | ||||
| 		branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) { | ||||
| 				if (branchChoisBox.getItems().get((int) new_value).toString() == "beta") { | ||||
| @ -477,28 +424,26 @@ public class MainWindowController { | ||||
| 			} | ||||
| 		}); | ||||
|          | ||||
|         fontsizeSlider.valueProperty().addListener(new ChangeListener<Number>() { | ||||
| 			 @Override | ||||
| 			public void changed(ObservableValue<? extends Number> ov,Number old_val, Number new_val) { | ||||
| 				setSize(fontsizeSlider.getValue());  | ||||
| 				 | ||||
| 				if(name != null){ | ||||
| 		fontsizeSlider.valueProperty().addListener(new ChangeListener<Number>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { | ||||
| 				setSize(fontsizeSlider.getValue()); | ||||
| 				if (name != null) { | ||||
| 					dbController.readCache(datPath); | ||||
| 				} | ||||
|  | ||||
| //				ta1.setFont(Font.font("System", size)); | ||||
| 				// ta1.setFont(Font.font("System", size)); | ||||
| 				saveSettings(); | ||||
| 			 } | ||||
|         }); | ||||
| 			} | ||||
| 		}); | ||||
|          | ||||
|         like.setOnAction(new EventHandler<ActionEvent>() { | ||||
|             @Override | ||||
|             public void handle(ActionEvent event) { | ||||
|             	if(mode.equals("streaming")){ | ||||
|             		dbController.like(name,streamingFilms.get(selected).getStreamUrl()); | ||||
|             	}else{ | ||||
| 				dbController.like(name,localFilms.get(selected).getStreamUrl()); | ||||
|             	} | ||||
| 		like.setOnAction(new EventHandler<ActionEvent>() { | ||||
| 			@Override | ||||
| 			public void handle(ActionEvent event) { | ||||
| 				if (mode.equals("streaming")) { | ||||
| 					dbController.like(name, streamingFilms.get(selected).getStreamUrl()); | ||||
| 				} else { | ||||
| 					dbController.like(name, localFilms.get(selected).getStreamUrl()); | ||||
| 				} | ||||
| 				dbController.getFavStatus(name); | ||||
| 				try { | ||||
| 					dbController.refresh(name, selected); | ||||
| @ -507,78 +452,108 @@ public class MainWindowController { | ||||
| 				} | ||||
| 				refreshTable(); | ||||
| 			} | ||||
| 	    	}); | ||||
| 		}); | ||||
|          | ||||
|         dislike.setOnAction(new EventHandler<ActionEvent>() { | ||||
|             @Override | ||||
|             public void handle(ActionEvent event) { | ||||
|             	if(mode.equals("streaming")){ | ||||
|             		dbController.dislike(name,streamingFilms.get(selected).getStreamUrl()); | ||||
|             	}else{ | ||||
| 				dbController.dislike(name,localFilms.get(selected).getStreamUrl()); | ||||
|             	} | ||||
| 		dislike.setOnAction(new EventHandler<ActionEvent>() { | ||||
| 			@Override | ||||
| 			public void handle(ActionEvent event) { | ||||
| 				if (mode.equals("streaming")) { | ||||
| 					dbController.dislike(name, streamingFilms.get(selected).getStreamUrl()); | ||||
| 				} else { | ||||
| 					dbController.dislike(name, localFilms.get(selected).getStreamUrl()); | ||||
| 				} | ||||
| 				dbController.getFavStatus(name); | ||||
| 				try { | ||||
| 					dbController.refresh(name, selected); | ||||
| 				} catch (SQLException e) { | ||||
| 					LOGGER.error("There was a problem with the like/dislike function!",e); | ||||
| 					LOGGER.error("There was a problem with the like/dislike function!", e); | ||||
| 				} | ||||
| 				refreshTable(); | ||||
| 			} | ||||
| 	    	}); | ||||
| 		}); | ||||
|          | ||||
|         /** | ||||
|          * FIXME fix bug when sort by ASCENDING, wrong order | ||||
|          */ | ||||
|         columnRating.sortTypeProperty().addListener(new ChangeListener<SortType>() { | ||||
|             @Override | ||||
|             public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) { | ||||
|             	LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2); | ||||
|             	ArrayList<Integer> fav_true = new ArrayList<Integer>(); | ||||
|             	ArrayList<Integer> fav_false = new ArrayList<Integer>(); | ||||
|             	ObservableList<tableData> helpData; | ||||
|   	    		filterData.removeAll(filterData); | ||||
| //  	    	treeTableViewfilm.getSelectionModel().clearSelection(selected); | ||||
|   	    		root.getChildren().remove(0,root.getChildren().size()); | ||||
|   	    		 | ||||
|   	    		if(mode.equals("local")){ | ||||
|   	            	helpData = localFilms; | ||||
|   	    		}else{ | ||||
|   	    			helpData = streamingFilms; | ||||
|   	    		} | ||||
|                | ||||
|   	    		 | ||||
|   	    		for(int i = 0;i<helpData.size();i++){ | ||||
|   	    			if(helpData.get(i).getRating()==1.0){ | ||||
|   	    				fav_true.add(i); | ||||
|   	    			}else{ | ||||
|   	    				fav_false.add(i); | ||||
|   	    			} | ||||
|   	    		} | ||||
|   	    		if(paramT2.toString().equals("DESCENDING")){ | ||||
|   	    			LOGGER.info("Absteigend");	//Debug, delete? | ||||
|   	  	    		for(int i = 0;i<fav_true.size();i++){ | ||||
|   	  	    			filterData.add(helpData.get(fav_true.get(i))); | ||||
|   	  	    		} | ||||
|   	  	    		for(int i = 0;i<fav_false.size();i++){ | ||||
|   	  	    			filterData.add(helpData.get(fav_false.get(i))); | ||||
|   	  	    		} | ||||
|   	    		}else{ | ||||
|   	  	    		for(int i = 0;i<fav_false.size();i++){ | ||||
|   	  	    			filterData.add(helpData.get(fav_false.get(i))); | ||||
|   	  	    		} | ||||
|   	  	    		for(int i = 0;i<fav_true.size();i++){ | ||||
|   	  	    			filterData.add(helpData.get(fav_true.get(i))); | ||||
|   	  	    		} | ||||
|   	    		} | ||||
|   	    		 | ||||
|   	    		LOGGER.info(filterData.size());	//Debug, delete? | ||||
|     	    	for(int i = 0; i < filterData.size(); i++){ | ||||
| //    	    		LOGGER.info(filterData.get(i).getTitle()+"; "+filterData.get(i).getRating()); // Debugging | ||||
|     				root.getChildren().add(new TreeItem<tableData>(filterData.get(i)));	//add filtered data to root node after search | ||||
|     			} | ||||
|             } | ||||
|       }); | ||||
| 		/** | ||||
| 		 * FIXME fix bug when sort by ASCENDING, wrong order | ||||
| 		 */ | ||||
| 		columnRating.sortTypeProperty().addListener(new ChangeListener<SortType>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, | ||||
| 					SortType paramT2) { | ||||
| 				LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2); | ||||
| 				ArrayList<Integer> fav_true = new ArrayList<Integer>(); | ||||
| 				ArrayList<Integer> fav_false = new ArrayList<Integer>(); | ||||
| 				ObservableList<tableData> helpData; | ||||
| 				filterData.removeAll(filterData); | ||||
| //				treeTableViewfilm.getSelectionModel().clearSelection(selected); | ||||
| 				root.getChildren().remove(0, root.getChildren().size()); | ||||
|  | ||||
| 				if (mode.equals("local")) { | ||||
| 					helpData = localFilms; | ||||
| 				} else { | ||||
| 					helpData = streamingFilms; | ||||
| 				} | ||||
|  | ||||
| 				for (int i = 0; i < helpData.size(); i++) { | ||||
| 					if (helpData.get(i).getRating() == 1.0) { | ||||
| 						fav_true.add(i); | ||||
| 					} else { | ||||
| 						fav_false.add(i); | ||||
| 					} | ||||
| 				} | ||||
| 				if (paramT2.toString().equals("DESCENDING")) { | ||||
| 					LOGGER.info("Absteigend"); // Debug, delete? | ||||
| 					for (int i = 0; i < fav_true.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_true.get(i))); | ||||
| 					} | ||||
| 					for (int i = 0; i < fav_false.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_false.get(i))); | ||||
| 					} | ||||
| 				} else { | ||||
| 					for (int i = 0; i < fav_false.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_false.get(i))); | ||||
| 					} | ||||
| 					for (int i = 0; i < fav_true.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_true.get(i))); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				LOGGER.info(filterData.size()); // Debug, delete? | ||||
| 				for (int i = 0; i < filterData.size(); i++) { | ||||
| //					LOGGER.info(filterData.get(i).getTitle()+"; "+filterData.get(i).getRating()); // Debugging | ||||
| 					root.getChildren().add(new TreeItem<tableData>(filterData.get(i))); // add filtered data to root node after search | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
|          | ||||
| 		// Change-listener for treeTableViewfilm | ||||
| 		treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) { | ||||
| 				// last = selected; //for auto-play | ||||
| 				selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); // get selected item | ||||
| 				last = selected - 1; | ||||
| 				next = selected + 1; | ||||
| 				name = columnTitel.getCellData(selected); // get name of selected item | ||||
| 				datPath = columnStreamUrl.getCellData(selected); // get file path of selected item | ||||
|  | ||||
| 				if (mode.equals("local")) { | ||||
| 					if (localFilms.get(selected).getCached() == true) { | ||||
| 						LOGGER.info("loading from cache: " + name); | ||||
| 						dbController.readCache(datPath); | ||||
| 					} else { | ||||
| 						ApiQuery.startQuery(name, datPath); // start api query | ||||
| 					} | ||||
| 				} else { | ||||
| 					LOGGER.info(streamingFilms.size()); | ||||
| 					if (streamingFilms.get(selected).getCached() == true) { | ||||
| 						LOGGER.info("loading from cache: " + name); | ||||
| 						dbController.readCache(datPath); | ||||
| 					} else { | ||||
| 						ApiQuery.startQuery(name, datPath); // start api query | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
| 	 | ||||
| 	// initialize UI elements | ||||
| @ -587,7 +562,6 @@ public class MainWindowController { | ||||
| 		debugBtn.setDisable(true); // debugging button for tests | ||||
| 		debugBtn.setVisible(false); | ||||
|  | ||||
| 		filmDirTextField.setText(getPath()); | ||||
| 		versionLbl.setText("Version: " + version + " (Build: " + buildNumber + ")"); | ||||
| 		fontsizeSlider.setValue(getSize()); | ||||
| 		colorPicker.setValue(Color.valueOf(getColor())); | ||||
| @ -643,14 +617,14 @@ public class MainWindowController { | ||||
| 					vlcInfoDialog.show(); | ||||
| 				}else{ | ||||
| 					try { | ||||
| 						Runtime.getRuntime().exec(new String[] { "vlc", getPath()+"/"+ datPath}); | ||||
| 						Runtime.getRuntime().exec(new String[] { "vlc", datPath}); // TODO switch to ProcessBuilder | ||||
| 					} catch (IOException e) { | ||||
| 						showErrorMsg(errorPlay,e); | ||||
| 					} | ||||
| 				} | ||||
| 			}else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){ | ||||
| 					try { | ||||
| 						Desktop.getDesktop().open(new File(getPath()+"\\"+ datPath)); | ||||
| 						Desktop.getDesktop().open(new File(datPath)); | ||||
| 					} catch (IOException e) { | ||||
| 						showErrorMsg(errorPlay,e); | ||||
| 					} | ||||
| @ -665,11 +639,12 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void openfolderbtnclicked(){ | ||||
| 		try { | ||||
| 			Desktop.getDesktop().open(new File(getPath()));	//open path when button is clicked | ||||
| 		} catch (IOException e) { | ||||
| 			e.printStackTrace(); | ||||
| 		} | ||||
| 		//TODO rework | ||||
| //		try { | ||||
| //			Desktop.getDesktop().open(new File(getPath()));	//open path when button is clicked | ||||
| //		} catch (IOException e) { | ||||
| //			e.printStackTrace(); | ||||
| //		} | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| @ -693,38 +668,15 @@ public class MainWindowController { | ||||
| 	@FXML | ||||
| 	private void settingsBtnclicked(){ | ||||
| 		if(settingsTrue == false){ | ||||
| 			if(streamingSettingsTrue == true){ | ||||
| 				streamingSettingsAnchorPane.setVisible(false); | ||||
| 				streamingSettingsTrue = false; | ||||
| 			} | ||||
| 			settingsScrollPane.setVisible(true);	 | ||||
| 			settingsTrue = true; | ||||
| 		}else{ | ||||
| 			settingsScrollPane.setVisible(false); | ||||
| 			setPath(filmDirTextField.getText()); | ||||
| 			saveSettings(); | ||||
| 			settingsTrue = false; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * TODO additional info about the "streaming.json" | ||||
| 	 */ | ||||
| 	@FXML | ||||
| 	private void streamingSettingsBtnclicked(){ | ||||
| 		if(streamingSettingsTrue == false){ | ||||
| 			if(settingsTrue == true){ | ||||
| 				settingsScrollPane.setVisible(false); | ||||
| 				settingsTrue = false; | ||||
| 			} | ||||
| 			streamingSettingsAnchorPane.setVisible(true);			 | ||||
| 			streamingSettingsTrue = true;	 | ||||
| 			}else{ | ||||
| 				streamingSettingsAnchorPane.setVisible(false); | ||||
| 				streamingSettingsTrue = false; | ||||
| 			}					 | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void switchBtnclicked(){ | ||||
| 		if(mode.equals("local")){	//switch to streaming mode | ||||
| @ -738,41 +690,38 @@ public class MainWindowController { | ||||
| 		root.getChildren().remove(0,root.getChildren().size()); | ||||
| 		addDataUI(); | ||||
| 		settingsScrollPane.setVisible(false); | ||||
| 		streamingSettingsAnchorPane.setVisible(false); | ||||
| 		sideMenuSlideOut();		//disables side-menu | ||||
| 		menuTrue = false; | ||||
| 		settingsTrue = false; | ||||
| 		streamingSettingsTrue = false; | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void debugBtnclicked(){ | ||||
| 		//for testing | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void filmDirTextFieldAction(){ | ||||
| 		setPath(filmDirTextField.getText()); | ||||
| 		saveSettings(); | ||||
| 	private void addDirectoryBtnAction(){ | ||||
| 		File selectedFolder = directoryChooser.showDialog(null); | ||||
| 		if (selectedFolder != null && selectedFolder.exists()) { | ||||
| 			addSource(selectedFolder.getPath(), "local"); | ||||
| 			dbController.refreshDataBase(); | ||||
| 		} else { | ||||
| 			LOGGER.error("The selected folder dosen't exist!"); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void directoryBtnAction(){ | ||||
| 		selectedFolder = directoryChooser.showDialog(null);   | ||||
|         if(selectedFolder == null){ | ||||
|         	LOGGER.warn("No Directory selected"); | ||||
|         }else{ | ||||
|         	setPath(selectedFolder.getAbsolutePath()); | ||||
|         	saveSettings(); | ||||
|         	filmDirTextField.setText(getPath()); | ||||
| 			try { | ||||
| 				Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar");	//start again | ||||
| 				System.exit(0);	//finishes itself | ||||
| 			} catch (IOException e) { | ||||
| 				LOGGER.error("error while restarting HomeFlix", e); | ||||
| 			} | ||||
|         } | ||||
| 	private void addStreamSourceBtnAction(){ | ||||
| 		FileChooser fileChooser = new FileChooser(); | ||||
| 		fileChooser.setTitle("Open Resource File"); | ||||
| 		File selectedFile = fileChooser.showOpenDialog(main.getPrimaryStage()); | ||||
| 		if (selectedFile != null && selectedFile.exists()) { | ||||
| 			addSource(selectedFile.getPath(), "local"); | ||||
| 			dbController.refreshDataBase(); | ||||
| 		} else { | ||||
| 			LOGGER.error("The selected file dosen't exist!"); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| @ -799,29 +748,6 @@ public class MainWindowController { | ||||
| 		saveSettings(); | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void streamingPathTextFieldAction(){ | ||||
| 		// | ||||
| 	} | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void streamingDirectoryBtnAction(){ | ||||
| 		selectedStreamingFolder = directoryChooser.showDialog(null);   | ||||
| 		if(selectedStreamingFolder == null){ | ||||
| 				LOGGER.warn("No Directory selected"); | ||||
| 		}else{ | ||||
| 			setStreamingPath(selectedStreamingFolder.getAbsolutePath()); | ||||
| 			saveSettings(); | ||||
| 			streamingPathTextField.setText(getStreamingPath()); | ||||
| 			try { | ||||
| 				Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar");	//start again | ||||
| 				System.exit(0);	//finishes itself | ||||
| 			} catch (IOException e) { | ||||
| 				LOGGER.error("error while restarting HomeFlix", e); | ||||
| 			} | ||||
| 			} | ||||
| 	} | ||||
| 	 | ||||
| 	private void refreshTable(){ | ||||
| 		if(mode.equals("local")){ | ||||
| 		root.getChildren().set(selected, new TreeItem<tableData>(localFilms.get(selected))); | ||||
| @ -858,32 +784,28 @@ public class MainWindowController { | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	void loadStreamingSettings() { | ||||
| 		if (getStreamingPath().equals("") || getStreamingPath().equals(null)) { | ||||
| 			LOGGER.warn("Kein Pfad angegeben"); | ||||
| 		} else { | ||||
| 			String[] entries = new File(getStreamingPath()).list(); | ||||
| 			for (int i = 0; i < entries.length; i++) { | ||||
| 				if (entries[i].endsWith(".json")) { | ||||
| 					String titel = ohneEndung(entries[i]); | ||||
| 					String data = entries[i]; | ||||
| 					streamingData.add(new tableData(1, 1, 1, 5.0, "1", titel, data, imv1, false)); | ||||
| 				} | ||||
| 			} | ||||
| 			for (int i = 0; i < streamingData.size(); i++) { | ||||
| 				streamingRoot.getChildren().add(new TreeItem<tableData>(streamingData.get(i))); // adds data to root-node | ||||
| 			} | ||||
| 		} | ||||
| 	public void addSourceToTable(String path, String mode) { | ||||
| 		sourcesList.add(new tableData(1, 1, 1, 5.0, "1", path, mode, imv1, false)); | ||||
| 		streamingRoot.getChildren().add(new TreeItem<tableData>(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node | ||||
| 	} | ||||
| 	 | ||||
| 	// removes the ending | ||||
| 	private String ohneEndung(String str) { | ||||
| 		if (str == null) | ||||
| 			return null; | ||||
| 		int pos = str.lastIndexOf("."); | ||||
| 		if (pos == -1) | ||||
| 			return str; | ||||
| 		return str.substring(0, pos); | ||||
| 	public void addSource(String path, String mode) { | ||||
| 		JsonObject source = null; | ||||
| 		JsonArray newsources = null; | ||||
|  | ||||
| 		try { | ||||
| 			// read old array | ||||
| 			newsources = Json.parse(new FileReader(main.getDirectory() + "/sources.json")).asArray(); | ||||
|  | ||||
| 			// add new source | ||||
| 			Writer writer = new FileWriter(main.getDirectory() + "/sources.json"); | ||||
| 			source = Json.object().add("path", path).add("mode", mode); | ||||
| 			newsources.add(source); | ||||
| 			newsources.writeTo(writer); | ||||
| 			writer.close(); | ||||
| 		} catch (IOException e) { | ||||
| 			LOGGER.error(e); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	//set color of UI-Elements | ||||
| @ -897,17 +819,15 @@ public class MainWindowController { | ||||
| 		sideMenuVBox.setStyle(style); | ||||
| 		topHBox.setStyle(style); | ||||
| 		searchTextField.setFocusColor(Color.valueOf(getColor())); | ||||
| 		filmDirTextField.setFocusColor(Color.valueOf(getColor())); | ||||
|  | ||||
| 		if (icolor.compareTo(ccolor) == -1) { | ||||
| 			dialogBtnStyle = btnStyleWhite; | ||||
| 			settingsBtn.setStyle("-fx-text-fill: WHITE;"); | ||||
| 			streamingSettingsBtn.setStyle("-fx-text-fill: WHITE;"); | ||||
| 			switchBtn.setStyle("-fx-text-fill: WHITE;"); | ||||
| 			aboutBtn.setStyle("-fx-text-fill: WHITE;"); | ||||
| 			debugBtn.setStyle("-fx-text-fill: WHITE;"); | ||||
| 			directoryBtn.setStyle(btnStyleWhite); | ||||
| 			streamingDirectoryBtn.setStyle(btnStyleWhite); | ||||
| 			addDirectoryBtn.setStyle(btnStyleWhite); | ||||
| 			addStreamSourceBtn.setStyle(btnStyleWhite); | ||||
| 			updateBtn.setStyle(btnStyleWhite); | ||||
| 			playbtn.setStyle(btnStyleWhite); | ||||
| 			openfolderbtn.setStyle(btnStyleWhite); | ||||
| @ -920,12 +840,11 @@ public class MainWindowController { | ||||
| 		} else { | ||||
| 			dialogBtnStyle = btnStyleBlack; | ||||
| 			settingsBtn.setStyle("-fx-text-fill: BLACK;"); | ||||
| 			streamingSettingsBtn.setStyle("-fx-text-fill: BLACK;"); | ||||
| 			switchBtn.setStyle("-fx-text-fill: BLACK;"); | ||||
| 			aboutBtn.setStyle("-fx-text-fill: BLACK;"); | ||||
| 			debugBtn.setStyle("-fx-text-fill: BLACK;"); | ||||
| 			directoryBtn.setStyle(btnStyleBlack); | ||||
| 			streamingDirectoryBtn.setStyle(btnStyleBlack); | ||||
| 			addDirectoryBtn.setStyle(btnStyleBlack); | ||||
| 			addStreamSourceBtn.setStyle(btnStyleBlack); | ||||
| 			updateBtn.setStyle(btnStyleBlack); | ||||
| 			playbtn.setStyle(btnStyleBlack); | ||||
| 			openfolderbtn.setStyle(btnStyleBlack); | ||||
| @ -944,36 +863,21 @@ public class MainWindowController { | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	// slide in in 400ms | ||||
| 	private void sideMenuSlideIn() { | ||||
| 		sideMenuVBox.setVisible(true); | ||||
| 		// fade in from 40% to 100% opacity in 400ms | ||||
| 		FadeTransition fadeTransition = new FadeTransition(Duration.millis(400), sideMenuVBox); | ||||
| 		fadeTransition.setFromValue(0.4); | ||||
| 		fadeTransition.setToValue(1.0); | ||||
| 		// slide in in 400ms | ||||
| 		TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox); | ||||
| 		translateTransition.setFromX(-150); | ||||
| 		translateTransition.setToX(0); | ||||
| 		// in case both animations are used (add (fadeTransition, translateTransition) in the second line under this command) | ||||
| 		ParallelTransition parallelTransition = new ParallelTransition(); | ||||
| 		parallelTransition.getChildren().addAll(translateTransition);// (fadeTransition, translateTransition); | ||||
| 		parallelTransition.play(); | ||||
| 		translateTransition.play(); | ||||
| 	} | ||||
| 	 | ||||
| 	// slide out in 400ms | ||||
| 	private void sideMenuSlideOut() { | ||||
| 		// sideMenuVBox.setVisible(false); | ||||
| 		// fade out from 100% to 40% opacity in 400ms | ||||
| 		FadeTransition fadeTransition = new FadeTransition(Duration.millis(400), sideMenuVBox); | ||||
| 		fadeTransition.setFromValue(1.0); | ||||
| 		fadeTransition.setToValue(0.4); | ||||
| 		// slide out in 400ms | ||||
| 		TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox); | ||||
| 		translateTransition.setFromX(0); | ||||
| 		translateTransition.setToX(-150); | ||||
| 		// in case both animations are used (add (fadeTransition, translateTransition) in the second line under this command) | ||||
| 		ParallelTransition parallelTransition = new ParallelTransition(); | ||||
| 		parallelTransition.getChildren().addAll(translateTransition);// (fadeTransition, translateTransition); | ||||
| 		parallelTransition.play(); | ||||
| 		translateTransition.play(); | ||||
| 	} | ||||
| 	 | ||||
| 	void setLocalUI() { | ||||
| @ -993,14 +897,11 @@ public class MainWindowController { | ||||
| 		} | ||||
| 		aboutBtn.setText(getBundle().getString("info")); | ||||
| 		settingsBtn.setText(getBundle().getString("settings")); | ||||
| 		streamingSettingsBtn.setText(getBundle().getString("streamingSettings")); | ||||
| 		filmDirTextField.setPromptText(getBundle().getString("filmDirTextField")); | ||||
| 		streamingPathTextField.setPromptText(getBundle().getString("filmDirTextField")); | ||||
| 		searchTextField.setPromptText(getBundle().getString("tfSearch")); | ||||
| 		openfolderbtn.setText(getBundle().getString("openFolder")); | ||||
| 		updateBtn.setText(getBundle().getString("checkUpdates")); | ||||
| 		directoryBtn.setText(getBundle().getString("chooseFolder")); | ||||
| 		streamingDirectoryBtn.setText(getBundle().getString("chooseFolder")); | ||||
| 		addDirectoryBtn.setText(getBundle().getString("addDirectory")); | ||||
| 		addStreamSourceBtn.setText(getBundle().getString("addStreamSource")); | ||||
| 		homeflixSettingsLbl.setText(getBundle().getString("homeflixSettingsLbl")); | ||||
| 		mainColorLbl.setText(getBundle().getString("mainColorLbl")); | ||||
| 		fontsizeLbl.setText(getBundle().getString("fontsizeLbl")); | ||||
| @ -1059,7 +960,6 @@ public class MainWindowController { | ||||
| 	public void saveSettings() { | ||||
| 		LOGGER.info("saving settings ..."); | ||||
| 		try { | ||||
| 			props.setProperty("path", getPath()); // writes path into property | ||||
| 			props.setProperty("color", getColor()); | ||||
| 			props.setProperty("autoUpdate", String.valueOf(isAutoUpdate())); | ||||
| 			props.setProperty("useBeta", String.valueOf(isUseBeta())); | ||||
| @ -1085,12 +985,12 @@ public class MainWindowController { | ||||
| 			InputStream inputStream = new FileInputStream(main.getConfigFile()); | ||||
| 			props.loadFromXML(inputStream); // new input-stream from .xml | ||||
|  | ||||
| 			try { | ||||
| 				setPath(props.getProperty("path")); // read path from property | ||||
| 			} catch (Exception e) { | ||||
| 				LOGGER.error("cloud not load path", e); | ||||
| 				setPath(""); | ||||
| 			} | ||||
| //			try { | ||||
| //				setPath(props.getProperty("path")); // read path from property | ||||
| //			} catch (Exception e) { | ||||
| //				LOGGER.error("cloud not load path", e); | ||||
| //				setPath(""); | ||||
| //			} | ||||
|  | ||||
| 			try { | ||||
| 				setStreamingPath(props.getProperty("streamingPath")); | ||||
| @ -1198,14 +1098,6 @@ public class MainWindowController { | ||||
| 		return color; | ||||
| 	} | ||||
|  | ||||
| 	public void setPath(String input) { | ||||
| 		this.path = input; | ||||
| 	} | ||||
|  | ||||
| 	public String getPath() { | ||||
| 		return path; | ||||
| 	} | ||||
|  | ||||
| 	public void setStreamingPath(String input) { | ||||
| 		this.streamingPath = input; | ||||
| 	} | ||||
| @ -1270,12 +1162,12 @@ public class MainWindowController { | ||||
| 		this.streamingFilms = streamingFilms; | ||||
| 	} | ||||
|  | ||||
| 	public ObservableList<tableData> getStreamingData() { | ||||
| 		return streamingData; | ||||
| 	public ObservableList<tableData> getSourcesList() { | ||||
| 		return sourcesList; | ||||
| 	} | ||||
|  | ||||
| 	public void setStreamingData(ObservableList<tableData> streamingData) { | ||||
| 		this.streamingData = streamingData; | ||||
| 	public void setSourcesList(ObservableList<tableData> sourcesList) { | ||||
| 		this.sourcesList = sourcesList; | ||||
| 	} | ||||
|  | ||||
| 	public String getRatingSortType() { | ||||
|  | ||||
| @ -64,27 +64,26 @@ public class DBController { | ||||
| 	private Image favorite_black = new Image("icons/ic_favorite_black_18dp_1x.png"); | ||||
| 	private Image favorite_border_black = new Image("icons/ic_favorite_border_black_18dp_1x.png"); | ||||
| 	private List<String> filmsdbAll = new ArrayList<String>(); | ||||
| 	private List<String> filmsdbDir = new ArrayList<String>(); | ||||
| 	private List<String> filmsdbDir = new ArrayList<String>(); // needed | ||||
| 	private List<String> filmsdbStream = new ArrayList<String>(); | ||||
| 	private List<String> filmsdbStreamURL = new ArrayList<String>(); | ||||
| 	private List<String> filmsdbStreamURL = new ArrayList<String>(); // needed | ||||
| 	private List<String> filmsAll = new ArrayList<String>(); | ||||
| 	private List<String> filmsDir = new ArrayList<String>(); | ||||
| 	private List<String> filmsDirURL = new ArrayList<String>(); | ||||
| //	private List<String> filmsDirURL = new ArrayList<String>(); | ||||
| 	private List<String> filmsStream = new ArrayList<String>(); | ||||
| 	private List<String> filmsStreamURL = new ArrayList<String>();	 | ||||
| 	private List<String> filmsStreamURL = new ArrayList<String>(); // needed | ||||
| 	private List<String> filmsStreamData = new ArrayList<String>(); | ||||
| 	private Connection connection = null; | ||||
| 	private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName()); | ||||
| 	 | ||||
| 	public void init() { | ||||
| 		LOGGER.info("<========== starting loading sql ==========>"); | ||||
| 		loadDatabase(); | ||||
| 		initDatabaseConnection(); | ||||
| 		createDatabase(); | ||||
| 		loadData(); | ||||
| 		refreshDataBase(); | ||||
| 		LOGGER.info("<========== finished loading sql ==========>"); | ||||
| 	} | ||||
|  | ||||
| 	public void loadDatabase() { | ||||
| 	public void initDatabaseConnection() { | ||||
| 		DB_PATH = main.getDirectory() + "/Homeflix.db"; | ||||
| 		try { | ||||
| 			// create a database connection | ||||
| @ -97,11 +96,11 @@ public class DBController { | ||||
| 		LOGGER.info("ROM database loaded successfull"); | ||||
| 	} | ||||
| 	 | ||||
| 	public void createDatabase() {	 | ||||
| 		/** | ||||
| 		 * if tables don't exist create them | ||||
| 		 * cache table: streamUrl is primary key | ||||
| 		 */ | ||||
| 	/** | ||||
| 	 * if tables don't exist create them | ||||
| 	 * cache table: streamUrl is primary key | ||||
| 	 */ | ||||
| 	private void createDatabase() {	 | ||||
| 		try { | ||||
| 			Statement stmt = connection.createStatement(); | ||||
| 			stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, favIcon, cached)"); | ||||
| @ -114,7 +113,10 @@ public class DBController { | ||||
| 			stmt.close(); | ||||
| 		} catch (SQLException e) { | ||||
| 			LOGGER.error(e); | ||||
| 		}  | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	private void loadDatabase() { | ||||
| 		 | ||||
| 		// get all entries from the tables | ||||
| 		try { | ||||
| @ -137,123 +139,64 @@ public class DBController { | ||||
| 			LOGGER.error("Ups! an error occured!", e); | ||||
| 		} | ||||
| 			 | ||||
| 		// getting all files from the selected directory | ||||
| 		if (new File(mainWindowController.getPath()).exists()) { | ||||
| 			for (String entry : new File(mainWindowController.getPath()).list()) { | ||||
| 				filmsDir.add(cutOffEnd(entry)); | ||||
| 				filmsDirURL.add(entry);		 | ||||
| //				System.out.println(cutOffEnd(entry)); | ||||
| //				System.out.println(entry); | ||||
| 			} | ||||
| 		} else { | ||||
| 			LOGGER.error(mainWindowController.getPath() + "dosen't exist!"); | ||||
| 		} | ||||
|  | ||||
| 		// getting all entries from the streaming lists | ||||
| 		for (int i = 0; i < mainWindowController.getStreamingData().size(); i++) { | ||||
| 			String fileName = mainWindowController.getStreamingPath() + "/" | ||||
| 					+ mainWindowController.getStreamingData().get(i).getStreamUrl(); | ||||
| 			try { | ||||
| 				JsonObject object = Json.parse(new FileReader(fileName)).asObject(); | ||||
| 				JsonArray items = object.get("entries").asArray(); | ||||
| 				for (JsonValue item : items) { | ||||
| 					filmsStream.add(item.asObject().getString("titel", "")); | ||||
| 					filmsStreamURL.add(item.asObject().getString("streamUrl", "")); | ||||
| 					filmsStreamData.add(fileName); | ||||
| 					 | ||||
| //					System.out.println(item.asObject().getString("titel", "")); | ||||
| //					System.out.println(item.asObject().getString("streamUrl", "")); | ||||
| //					System.out.println(fileName); | ||||
| 				} | ||||
| 			} catch (IOException e) { | ||||
| 				e.printStackTrace(); | ||||
| 			} | ||||
| 		} | ||||
| 			 | ||||
| 		// add all entries to filmsAll and filmsdbAl, for later comparing | ||||
| 		filmsAll.addAll(filmsDir); | ||||
| 		filmsAll.addAll(filmsStream); | ||||
| 		filmsdbAll.addAll(filmsdbDir); | ||||
| 		filmsdbAll.addAll(filmsdbStream); | ||||
| 		LOGGER.info("films in directory: " + filmsAll.size()); | ||||
| 		LOGGER.info("filme in db: " + filmsdbAll.size()); | ||||
| 		 | ||||
| 		/** | ||||
| 		 * if filmsdbAll.size() == 0 the database is empty, we need to fill it with loadFilms() | ||||
| 		 * else check if there is something to remove or to add | ||||
| 		 */ | ||||
| 		if (filmsdbAll.size() == 0) { | ||||
| 			loadFilms(); | ||||
| 		} else { | ||||
| 			try { | ||||
| 				checkAddEntry(); | ||||
| 				checkRemoveEntry(); | ||||
| 			} catch (IOException | SQLException e) { | ||||
| 				e.printStackTrace(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	private void loadFilms() { | ||||
| 		PreparedStatement ps; | ||||
| 		PreparedStatement psS;	 | ||||
| 		LOGGER.info("Database is empty, filling tables ..."); | ||||
| 	// load the sources from sources.json | ||||
| 	private void loadSources() { | ||||
| 		// remove sources from table | ||||
| 		mainWindowController.getSourcesList().removeAll(mainWindowController.getSourcesList()); | ||||
| 		mainWindowController.streamingRoot.getChildren().removeAll(mainWindowController.streamingRoot.getChildren()); | ||||
| 		 | ||||
| 		try { | ||||
| 			ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?, ?)"); | ||||
| 			psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?, ?)"); | ||||
|  | ||||
| 			if (new File(mainWindowController.getPath()).exists()) { | ||||
| 				// go through all the files in the directory | ||||
| 				for (int j = 0; j != filmsDir.size(); j++) | ||||
| 				{ | ||||
| 					ps.setInt(1, 0); // rating as integer 1. column | ||||
| 					ps.setString(2, filmsDir.get(j)); // name as String without ending 2. column | ||||
| 					ps.setString(3, filmsDirURL.get(j)); // path as String 3. column | ||||
| 					ps.setString(4, "favorite_border_black"); | ||||
| 					ps.setBoolean(5, false); | ||||
| 					ps.addBatch(); // add command to prepared statement | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			if (mainWindowController.getStreamingPath().equals("") || mainWindowController.getStreamingPath().equals(null)) { | ||||
| 				LOGGER.warn("no path selected!"); | ||||
| 			} else { | ||||
| 				for (int i = 0; i < mainWindowController.getStreamingData().size(); i++) { | ||||
| 					String fileNamea = mainWindowController.getStreamingPath() + "/" | ||||
| 							+ mainWindowController.getStreamingData().get(i).getStreamUrl(); | ||||
| 			JsonArray sources = Json.parse(new FileReader(main.getDirectory() + "/sources.json")).asArray(); | ||||
| 			for (JsonValue source : sources) { | ||||
| 				String path = source.asObject().getString("path", ""); | ||||
| 				String mode = source.asObject().getString("mode", ""); | ||||
| 				mainWindowController.addSourceToTable(path, mode); // add source to source-table | ||||
| 				if (mode.equals("local")) { | ||||
| 					// getting all files from the selected directory | ||||
| 					if (new File(path).exists()) { | ||||
| 						for (String entry : new File(path).list()) { | ||||
| 							filmsAll.add(cutOffEnd(entry)); | ||||
| 						} | ||||
| 						LOGGER.info("added files from: " + path); | ||||
| 					} else { | ||||
| 						LOGGER.error(path + "dosen't exist!"); | ||||
| 					} | ||||
| 				} else { | ||||
| 					// getting all entries from the streaming lists | ||||
| 					try { | ||||
| 						JsonObject object = Json.parse(new FileReader(fileNamea)).asObject(); | ||||
| 						JsonObject object = Json.parse(new FileReader(path)).asObject(); | ||||
| 						JsonArray items = object.get("entries").asArray(); | ||||
| 						for (JsonValue item : items) { | ||||
| 							psS.setInt(1, item.asObject().getInt("year", 0)); | ||||
| 							psS.setInt(2, item.asObject().getInt("season", 0)); | ||||
| 							psS.setInt(3, item.asObject().getInt("episode", 0)); | ||||
| 							psS.setInt(4, 0); | ||||
| 							psS.setString(5, item.asObject().getString("resolution", "")); | ||||
| 							psS.setString(6, item.asObject().getString("titel", "")); | ||||
| 							psS.setString(7, item.asObject().getString("streamUrl", "")); | ||||
| 							psS.setString(8, "favorite_border_black"); | ||||
| 							psS.setBoolean(9, false); | ||||
| 							psS.addBatch(); // add command to prepared statement | ||||
| 							filmsStream.add(item.asObject().getString("titel", "")); | ||||
| 							filmsStreamURL.add(item.asObject().getString("streamUrl", "")); | ||||
| 							filmsStreamData.add(path); | ||||
| 							// TODO check if all this is needed, maybe only use one table! | ||||
| //							System.out.println(item.asObject().getString("titel", "")); | ||||
| //							System.out.println(item.asObject().getString("streamUrl", "")); | ||||
| //							System.out.println(fileName); | ||||
| 						} | ||||
| 						LOGGER.info("added films from: " + path); | ||||
| 					} catch (IOException e) { | ||||
| 						LOGGER.error(e); | ||||
| 						e.printStackTrace(); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			ps.executeBatch(); // execute statement to write entries into table | ||||
| 			psS.executeBatch(); | ||||
| 			connection.commit(); | ||||
| 			ps.close(); | ||||
| 			psS.close(); | ||||
| 		} catch (SQLException e) { | ||||
| 			LOGGER.error(e); | ||||
| 		} catch (Exception e) { | ||||
| 			e.printStackTrace(); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	// loading data from database to mainWindowController  | ||||
| 	public void loadData() { | ||||
| 	public void loadDataToMWC() { | ||||
| 		LOGGER.info("loading data to mwc ..."); | ||||
| 		try { | ||||
| 			//load local Data | ||||
| @ -333,39 +276,84 @@ public class DBController { | ||||
| 			}  | ||||
| 		}  | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * refresh database to contain all (new added) entries | ||||
| 	 * refresh the MainWindowController content, | ||||
| 	 * to contain all (new added) entries from the database | ||||
| 	 */ | ||||
| 	public void refreshDataBase() { | ||||
| 		LOGGER.info("refreshing the Database ..."); | ||||
| 		 | ||||
| 		// clean all ArraLists | ||||
| 		filmsdbAll.removeAll(filmsdbAll); | ||||
| 		filmsdbDir.removeAll(filmsdbDir); | ||||
| 		filmsdbStream.removeAll(filmsdbStream); | ||||
| 		filmsdbStreamURL.removeAll(filmsdbStreamURL); | ||||
| 		filmsAll.removeAll(filmsAll); | ||||
| 		filmsStream.removeAll(filmsStream); | ||||
| 		filmsStreamURL.removeAll(filmsStreamURL); | ||||
| 		filmsStreamData.removeAll(filmsStreamData); | ||||
| 		 | ||||
| 		loadSources(); // reload all sources | ||||
| 		loadDatabase(); // reload all films saved in the DB | ||||
| 		 | ||||
| 		 | ||||
| 		try { | ||||
| 			checkAddEntry(); | ||||
| 			checkRemoveEntry(); | ||||
| 		} catch (Exception e) { | ||||
| 			LOGGER.error("Error while refreshing the database", e); | ||||
| 		} | ||||
| 		 | ||||
| 		// remove all films from the mwc lists | ||||
| 		mainWindowController.getLocalFilms().removeAll(mainWindowController.getLocalFilms()); | ||||
| 		mainWindowController.getStreamingFilms().removeAll(mainWindowController.getStreamingFilms()); | ||||
| 		mainWindowController.root.getChildren().removeAll(mainWindowController.root.getChildren()); | ||||
| 		 | ||||
| 		loadDataToMWC(); // load the new data to the mwc | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * check if there are any entries that have been removed from the film-directory | ||||
| 	 * @throws SQLException | ||||
| 	 */ | ||||
| 	private void checkRemoveEntry() throws SQLException { | ||||
| 	private void checkRemoveEntry() { | ||||
| 		LOGGER.info("checking for entrys to remove to DB ..."); | ||||
| 		Statement stmt = connection.createStatement(); | ||||
|  | ||||
| 		for (int i = 0; i < filmsdbDir.size(); i++) { | ||||
| 			if (!filmsDir.contains(filmsdbDir.get(i))) { | ||||
| 				try { | ||||
| 					stmt.executeUpdate("delete from film_local where titel = \"" + filmsdbDir.get(i) + "\""); | ||||
| 		 | ||||
| 		try { | ||||
| 			Statement stmt = connection.createStatement(); | ||||
| 			 | ||||
| 			for (String entry : filmsdbDir) { | ||||
| 				if (!filmsAll.contains(cutOffEnd(entry))) { | ||||
| 					stmt.executeUpdate("delete from film_local where titel = \"" + entry + "\""); | ||||
| 					connection.commit(); | ||||
| 					stmt.close(); | ||||
| 					LOGGER.info("removed \"" + filmsdbDir.get(i) + "\" from database"); | ||||
| 				} catch (Exception e) { | ||||
| 					e.printStackTrace(); | ||||
| 					LOGGER.info("removed \"" + entry + "\" from database"); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		for (int j = 0; j < filmsdbStreamURL.size(); j++) { | ||||
| 			if (!filmsStreamURL.contains(filmsdbStreamURL.get(j))) { | ||||
| 				try { | ||||
| 					stmt.executeUpdate("delete from film_streaming where titel = \"" + filmsdbStream.get(j) + "\""); | ||||
| 			 | ||||
| 			// TODO needs testing, then remove 1 | ||||
| 			for (String entry : filmsdbStreamURL) { | ||||
| 				if (!filmsStreamURL.contains(entry)) { | ||||
| 					stmt.executeUpdate("delete from film_streaming where titel = \"" + entry + "\""); | ||||
| 					connection.commit(); | ||||
| 					stmt.close(); | ||||
| 					LOGGER.info("removed \"" + filmsdbStream.get(j) + "\" from database"); | ||||
| 				} catch (Exception e) { | ||||
| 					e.printStackTrace(); | ||||
| 					LOGGER.info("removed \"" + entry + "\" from database"); | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// this is 1 | ||||
| //			for (int j = 0; j < filmsdbStreamURL.size(); j++) { | ||||
| //				if (!filmsStreamURL.contains(filmsdbStreamURL.get(j))) { | ||||
| //					stmt.executeUpdate("delete from film_streaming where titel = \"" + filmsdbStream.get(j) + "\""); | ||||
| //					connection.commit(); | ||||
| //					stmt.close(); | ||||
| //					LOGGER.info("removed \"" + filmsdbStream.get(j) + "\" from database"); | ||||
| //				} | ||||
| //			} | ||||
| 			 | ||||
| 		} catch (Exception e) { | ||||
| 			LOGGER.error(e); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| @ -378,50 +366,60 @@ public class DBController { | ||||
| 	 */ | ||||
| 	private void checkAddEntry() throws SQLException, FileNotFoundException, IOException { | ||||
| 		String lastName = ""; | ||||
| 		LOGGER.info("checking for entrys to add to DB ..."); | ||||
| 		String[] entries = new File(mainWindowController.getPath()).list(); | ||||
| 		Statement stmt = connection.createStatement(); | ||||
| 		PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?, ?)"); | ||||
| 		int i = 0; | ||||
|  | ||||
| 		for (int a = 0; a < filmsDir.size(); a++) { | ||||
| 			if (!filmsdbDir.contains(filmsDir.get(a))) { | ||||
| 				stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entries[a]) + "\", \"" | ||||
| 						+ entries[a] + "\",\"favorite_border_black\",0)"); | ||||
| 				connection.commit(); | ||||
| 				stmt.close(); | ||||
| 				LOGGER.info("added \"" + filmsDir.get(a) + "\" to database"); | ||||
| 		LOGGER.info("checking for entrys to add to DB ..."); | ||||
| 		int a = 0; | ||||
| 		 | ||||
| 		// source is a single source of the sources list | ||||
| 		for (tableData source : mainWindowController.getSourcesList()) { | ||||
| 			// if it's a local source check the folder for new film | ||||
| 			if (source.getStreamUrl().equals("local")) { | ||||
| 				for (String entry : new File(source.getTitle()).list()) { | ||||
| 					if (!filmsdbAll.contains(cutOffEnd(entry))) { | ||||
| 						stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entry) + "\", \"" | ||||
| 								+ source.getTitle() + "/" + entry + "\",\"favorite_border_black\",0)"); | ||||
| 						connection.commit(); | ||||
| 						stmt.close(); | ||||
| 						LOGGER.info("added \"" + entry + "\" to database"); | ||||
| 						filmsAll.add(cutOffEnd(entry)); | ||||
| 					} | ||||
| 				} | ||||
| 			} else { | ||||
| 				// if it's a streaming source check the file for new films | ||||
| 				// TODO implement add check for streaming sources | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// TODO comment and rework | ||||
| 		for (int b = 0; b < filmsStreamURL.size(); b++) { | ||||
| 			if (filmsdbStreamURL.contains(filmsStreamURL.get(b))) { | ||||
| 			} else { | ||||
| 				if (lastName != "" && lastName != filmsStreamData.get(b)) { | ||||
| 					i = 0; | ||||
| 					a = 0; | ||||
| 				} | ||||
| 				lastName = filmsStreamData.get(b); | ||||
| 				JsonObject object = Json.parse(new FileReader(filmsStreamData.get(b))).asObject(); | ||||
| 				JsonArray items = object.get("entries").asArray(); | ||||
| 				LOGGER.info(items.size() + ", " + i + "; " + b); | ||||
| 				String streamURL = items.get(i).asObject().getString("streamUrl", ""); | ||||
| 				String titel = items.get(i).asObject().getString("titel", ""); | ||||
| 				LOGGER.info(items.size() + ", " + a + "; " + b); | ||||
| 				String streamURL = items.get(a).asObject().getString("streamUrl", ""); | ||||
| 				String titel = items.get(a).asObject().getString("titel", ""); | ||||
|  | ||||
| 				if (streamURL.equals(filmsStreamURL.get(b))) { | ||||
| 					LOGGER.info("added \"" + titel + "\""); | ||||
|  | ||||
| 					ps.setInt(1, items.get(i).asObject().getInt("year", 0)); | ||||
| 					ps.setInt(2, items.get(i).asObject().getInt("season", 0)); | ||||
| 					ps.setInt(3, items.get(i).asObject().getInt("episode", 0)); | ||||
| 					ps.setInt(1, items.get(a).asObject().getInt("year", 0)); | ||||
| 					ps.setInt(2, items.get(a).asObject().getInt("season", 0)); | ||||
| 					ps.setInt(3, items.get(a).asObject().getInt("episode", 0)); | ||||
| 					ps.setInt(4, 0); | ||||
| 					ps.setString(5, items.get(i).asObject().getString("resolution", "")); | ||||
| 					ps.setString(6, items.get(i).asObject().getString("titel", "")); | ||||
| 					ps.setString(7, items.get(i).asObject().getString("streamUrl", "")); | ||||
| 					ps.setString(5, items.get(a).asObject().getString("resolution", "")); | ||||
| 					ps.setString(6, items.get(a).asObject().getString("titel", "")); | ||||
| 					ps.setString(7, items.get(a).asObject().getString("streamUrl", "")); | ||||
| 					ps.setString(8, "favorite_border_black"); | ||||
| 					ps.setBoolean(9, false); | ||||
| 					ps.addBatch(); // adds the entry | ||||
| 				} | ||||
| 				i++; | ||||
| 				a++; | ||||
| 			} | ||||
| 		} | ||||
| 		ps.executeBatch(); | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
| <?import javafx.scene.control.Label?> | ||||
| <?import javafx.scene.control.ScrollPane?> | ||||
| <?import javafx.scene.control.Separator?> | ||||
| <?import javafx.scene.control.TableColumn?> | ||||
| <?import javafx.scene.control.TableView?> | ||||
| <?import javafx.scene.control.TreeTableView?> | ||||
| <?import javafx.scene.image.Image?> | ||||
| @ -68,11 +69,6 @@ | ||||
|                   <Font name="System Bold" size="15.0" /> | ||||
|                </font> | ||||
|             </JFXButton> | ||||
|             <JFXButton fx:id="streamingSettingsBtn" onAction="#streamingSettingsBtnclicked" prefHeight="32.0" prefWidth="150.0" textAlignment="CENTER"> | ||||
|                <font> | ||||
|                   <Font name="System Bold" size="15.0" /> | ||||
|                </font> | ||||
|             </JFXButton> | ||||
|             <JFXButton fx:id="switchBtn" onAction="#switchBtnclicked" prefHeight="32.0" prefWidth="150.0" textAlignment="CENTER"> | ||||
|                <font> | ||||
|                   <Font name="System Bold" size="15.0" /> | ||||
| @ -85,7 +81,7 @@ | ||||
|             </JFXButton> | ||||
|          </children> | ||||
|       </VBox> | ||||
|       <ScrollPane fx:id="settingsScrollPane" style="-fx-background: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0"> | ||||
|       <ScrollPane fx:id="settingsScrollPane" prefHeight="568.0" prefWidth="800.0" style="-fx-background: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0"> | ||||
|         <content> | ||||
|           <AnchorPane fx:id="settingsAnchorPane" style="-fx-background-color: white;"> | ||||
|                <children> | ||||
| @ -94,7 +90,7 @@ | ||||
|                         <Insets bottom="14.0" top="14.0" /> | ||||
|                      </padding> | ||||
|                      <children> | ||||
|                         <VBox prefHeight="193.0" prefWidth="797.0" spacing="25.0"> | ||||
|                         <VBox spacing="25.0"> | ||||
|                            <padding> | ||||
|                               <Insets left="24.0" /> | ||||
|                            </padding> | ||||
| @ -116,20 +112,6 @@ | ||||
|                                     <Insets left="-14.0" /> | ||||
|                                  </padding> | ||||
|                               </VBox> | ||||
|                               <VBox spacing="7.0"> | ||||
|                                  <padding> | ||||
|                                     <Insets right="5.0" /> | ||||
|                                  </padding> | ||||
|                                  <children> | ||||
|                                     <Label fx:id="filmDirectoryLbl" text="Film Directory" /> | ||||
|                                     <HBox spacing="10.0"> | ||||
|                                        <children> | ||||
|                                           <JFXTextField fx:id="filmDirTextField" maxWidth="305.0" minWidth="305.0" onAction="#filmDirTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="Film Directory" /> | ||||
|                                           <JFXButton fx:id="directoryBtn" onAction="#directoryBtnAction" prefHeight="32.0" text="choose directory" /> | ||||
|                                        </children> | ||||
|                                     </HBox> | ||||
|                                  </children> | ||||
|                               </VBox> | ||||
|                               <HBox minHeight="25.0" spacing="10.0"> | ||||
|                                  <children> | ||||
|                                     <Label fx:id="mainColorLbl" prefHeight="25.0" text="Main-Color" /> | ||||
| @ -166,6 +148,23 @@ | ||||
|                                  </children> | ||||
|                               </VBox> | ||||
|                               <Label fx:id="versionLbl" text="Version" /> | ||||
|                               <VBox spacing="10.0"> | ||||
|                                  <children> | ||||
|                                     <Label fx:id="sourcesLbl" text="Sources" /> | ||||
|                                     <HBox spacing="10.0"> | ||||
|                                        <children> | ||||
|                                           <JFXButton fx:id="addStreamSourceBtn" onAction="#addStreamSourceBtnAction" prefHeight="32.0" text="add stream source" /> | ||||
|                                           <JFXButton fx:id="addDirectoryBtn" onAction="#addDirectoryBtnAction" prefHeight="32.0" text="add directory" /> | ||||
|                                        </children> | ||||
|                                     </HBox> | ||||
|                                     <TableView fx:id="sourcesTable" maxWidth="430.0" minHeight="100.0" prefHeight="100.0" prefWidth="430.0"> | ||||
|                                       <columns> | ||||
|                                         <TableColumn fx:id="sourceColumn" prefWidth="290.0" resizable="false" text="Sources" /> | ||||
|                                         <TableColumn fx:id="modeColumn" minWidth="130.0" prefWidth="138.0" resizable="false" text="Mode" /> | ||||
|                                       </columns> | ||||
|                                     </TableView> | ||||
|                                  </children> | ||||
|                               </VBox> | ||||
|                            </children> | ||||
|                         </VBox> | ||||
|                         <VBox spacing="25.0"> | ||||
| @ -179,11 +178,5 @@ | ||||
|             </AnchorPane> | ||||
|         </content> | ||||
|       </ScrollPane> | ||||
|       <AnchorPane fx:id="streamingSettingsAnchorPane" layoutX="138.0" layoutY="33.0" prefHeight="566.0" prefWidth="760.0" style="-fx-background-color: #FFFFFF;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0"> | ||||
|          <children> | ||||
|             <JFXTextField fx:id="streamingPathTextField" layoutX="14.0" layoutY="14.0" onAction="#streamingPathTextFieldAction" prefWidth="250.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0" /> | ||||
|             <JFXButton fx:id="streamingDirectoryBtn" layoutX="263.0" layoutY="2.0" onAction="#streamingDirectoryBtnAction" prefHeight="25.0" prefWidth="115.0" AnchorPane.leftAnchor="260.0" AnchorPane.topAnchor="5.0" /> | ||||
|             <TableView fx:id="tableViewStreamingdata" layoutX="14.0" layoutY="44.0" prefHeight="517.0" prefWidth="370.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="40.0" /> | ||||
|          </children></AnchorPane> | ||||
| 	</children> | ||||
| </AnchorPane> | ||||
|  | ||||
| @ -10,7 +10,8 @@ openFolder = Ordner \u00F6ffnen | ||||
| #settings translations | ||||
| homeflixSettingsLbl = HomeFlix Einstellungen | ||||
| filmDirTextField = Pfad... | ||||
| chooseFolder = Ordner ausw\u00E4hlen | ||||
| addDirectory = Ordner hinzuf\u00FCgen | ||||
| addStreamSource = Stream Quelle hinzuf\u00FCgen | ||||
| mainColorLbl = Hauptfarbe: | ||||
| fontsizeLbl = Schriftgr\u00F6\u00DFe: | ||||
| languageLbl = Sprache: | ||||
|  | ||||
| @ -10,7 +10,8 @@ openFolder = open Folder | ||||
| #settings translations | ||||
| homeflixSettingsLbl = HomeFlix Settings | ||||
| filmDirTextField = Path... | ||||
| chooseFolder = choose Directory | ||||
| addDirectory = add directory | ||||
| addStreamSource = add stream source | ||||
| mainColorLbl = main color: | ||||
| fontsizeLbl = font size: | ||||
| languageLbl = local: | ||||
|  | ||||
		Reference in New Issue
	
	Block a user