parent
46cd28a642
commit
fdb39ea2f5
|
@ -37,6 +37,7 @@ import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -55,12 +56,8 @@ import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
|
||||||
|
|
||||||
import javafx.animation.TranslateTransition;
|
import javafx.animation.TranslateTransition;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
|
@ -168,21 +165,21 @@ public class MainWindowController {
|
||||||
private XMLController xmlController;
|
private XMLController xmlController;
|
||||||
private Stage primaryStage;
|
private Stage primaryStage;
|
||||||
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
|
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
|
||||||
|
|
||||||
private boolean menuTrue = false;
|
private boolean menuTrue = false;
|
||||||
|
|
||||||
private final String version = "0.7.0";
|
private final String version = "0.7.0";
|
||||||
private final String buildNumber = "169";
|
private final String buildNumber = "169";
|
||||||
private final String versionName = "toothless dragon";
|
private final String versionName = "toothless dragon";
|
||||||
private String btnStyle;
|
private String btnStyle;
|
||||||
|
|
||||||
private final int hashA = -647380320;
|
private final int hashA = -647380320;
|
||||||
private int last;
|
private int last;
|
||||||
private int indexTable;
|
private int indexTable;
|
||||||
private int indexList;
|
private int indexList;
|
||||||
private int next;
|
private int next;
|
||||||
private FilmTabelDataType currentTableFilm = new FilmTabelDataType("", "", "", "", false, null, null);
|
private FilmTabelDataType currentTableFilm = new FilmTabelDataType("", "", "", "", false, null, null);
|
||||||
|
|
||||||
private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)");
|
private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)");
|
||||||
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
|
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
|
||||||
private ObservableList<FilmTabelDataType> filterData = FXCollections.observableArrayList();
|
private ObservableList<FilmTabelDataType> filterData = FXCollections.observableArrayList();
|
||||||
|
@ -196,19 +193,19 @@ public class MainWindowController {
|
||||||
public MainWindowController() {
|
public MainWindowController() {
|
||||||
// the constructor
|
// the constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
xmlController = new XMLController();
|
xmlController = new XMLController();
|
||||||
dbController = DBController.getInstance();
|
dbController = DBController.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
LOGGER.info("Initializing Project-HomeFlix build " + buildNumber);
|
LOGGER.info("Initializing Project-HomeFlix build " + buildNumber);
|
||||||
|
|
||||||
xmlController.loadSettings(); // load settings
|
xmlController.loadSettings(); // load settings
|
||||||
checkAutoUpdate();
|
checkAutoUpdate();
|
||||||
|
|
||||||
// initialize the GUI and the DBController
|
// initialize the GUI and the DBController
|
||||||
primaryStage = (Stage) mainAnchorPane.getScene().getWindow(); // set primary stage for dialogs
|
primaryStage = (Stage) mainAnchorPane.getScene().getWindow(); // set primary stage for dialogs
|
||||||
initTabel();
|
initTabel();
|
||||||
|
@ -216,13 +213,13 @@ public class MainWindowController {
|
||||||
initActions();
|
initActions();
|
||||||
dbController.init();
|
dbController.init();
|
||||||
refreshAllFilms();
|
refreshAllFilms();
|
||||||
|
|
||||||
// load sources list in gui
|
// load sources list in gui
|
||||||
addSourceToTable();
|
addSourceToTable();
|
||||||
|
|
||||||
// posterModeStartup(); // TODO testing DO NOT USE THIS!!
|
// posterModeStartup(); // TODO testing DO NOT USE THIS!!
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 + ")");
|
||||||
|
@ -234,20 +231,20 @@ public class MainWindowController {
|
||||||
autoplayToggleBtn.setSelected(XMLController.isAutoplay());
|
autoplayToggleBtn.setSelected(XMLController.isAutoplay());
|
||||||
languageChoisBox.setItems(languages);
|
languageChoisBox.setItems(languages);
|
||||||
branchChoisBox.setItems(branches);
|
branchChoisBox.setItems(branches);
|
||||||
|
|
||||||
if (XMLController.isUseBeta()) {
|
if (XMLController.isUseBeta()) {
|
||||||
branchChoisBox.getSelectionModel().select(1);
|
branchChoisBox.getSelectionModel().select(1);
|
||||||
} else {
|
} else {
|
||||||
branchChoisBox.getSelectionModel().select(0);
|
branchChoisBox.getSelectionModel().select(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocalUI();
|
setLocalUI();
|
||||||
applyColor();
|
applyColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the tables (treeTableViewfilm and sourcesTable)
|
* Initialize the tables (treeTableViewfilm and sourcesTable) only needed for
|
||||||
* only needed for Tabel-Mode
|
* Tabel-Mode
|
||||||
*/
|
*/
|
||||||
private void initTabel() {
|
private void initTabel() {
|
||||||
|
|
||||||
|
@ -283,7 +280,6 @@ public class MainWindowController {
|
||||||
burgerTask.setRate(-1.0);
|
burgerTask.setRate(-1.0);
|
||||||
burgerTask.play();
|
burgerTask.play();
|
||||||
menuTrue = false;
|
menuTrue = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sideMenuSlideIn();
|
sideMenuSlideIn();
|
||||||
burgerTask.setRate(1.0);
|
burgerTask.setRate(1.0);
|
||||||
|
@ -294,173 +290,134 @@ public class MainWindowController {
|
||||||
settingsScrollPane.setVisible(false);
|
settingsScrollPane.setVisible(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
|
languageChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> {
|
||||||
@Override
|
String local = languageChoisBox.getItems().get((int) newValue).toString();
|
||||||
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) {
|
local = local.substring(local.length() - 6, local.length() - 1); // reading only en_US from English (en_US)
|
||||||
String local = languageChoisBox.getItems().get((int) new_value).toString();
|
XMLController.setUsrLocal(local);
|
||||||
local = local.substring(local.length() - 6, local.length() - 1); // reading only en_US from English (en_US)
|
setLocalUI();
|
||||||
XMLController.setUsrLocal(local);
|
xmlController.saveSettings();
|
||||||
setLocalUI();
|
|
||||||
xmlController.saveSettings();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
|
branchChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> {
|
||||||
@Override
|
if (branchChoisBox.getItems().get((int) newValue).toString() == "beta") {
|
||||||
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) {
|
XMLController.setUseBeta(true);
|
||||||
if (branchChoisBox.getItems().get((int) new_value).toString() == "beta") {
|
} else {
|
||||||
XMLController.setUseBeta(true);
|
XMLController.setUseBeta(false);
|
||||||
} else {
|
|
||||||
XMLController.setUseBeta(false);
|
|
||||||
}
|
|
||||||
xmlController.saveSettings();
|
|
||||||
}
|
}
|
||||||
|
xmlController.saveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
fontsizeSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
fontsizeSlider.valueProperty().addListener(e -> {
|
||||||
@Override
|
XMLController.setFontSize(fontsizeSlider.getValue());
|
||||||
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
|
if (!getCurrentTitle().isEmpty()) {
|
||||||
XMLController.setFontSize(fontsizeSlider.getValue());
|
setSelectedFilmInfo(dbController.readCache(getCurrentStreamUrl()));
|
||||||
if (!getCurrentTitle().isEmpty()) {
|
|
||||||
setSelectedFilmInfo(dbController.readCache(getCurrentStreamUrl()));
|
|
||||||
}
|
|
||||||
xmlController.saveSettings();
|
|
||||||
}
|
}
|
||||||
|
xmlController.saveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Table-Mode actions
|
// Table-Mode actions
|
||||||
searchTextField.textProperty().addListener(new ChangeListener<String>() {
|
searchTextField.textProperty().addListener((e, oldValue, newValue) -> {
|
||||||
@Override
|
filmRoot.getChildren().clear();
|
||||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
filterData.clear();
|
||||||
ObservableList<FilmTabelDataType> helpData;
|
filterData = filmsList.stream()
|
||||||
filterData.clear();
|
.filter(x -> x.getTitle().toLowerCase().contains(searchTextField.getText().toLowerCase()))
|
||||||
filmRoot.getChildren().clear();
|
.collect(Collectors.toCollection(FXCollections::observableArrayList));
|
||||||
|
|
||||||
helpData = filmsList;
|
addFilmsToTable(filterData);
|
||||||
|
|
||||||
for (int i = 0; i < helpData.size(); i++) {
|
if (searchTextField.getText().hashCode() == hashA) {
|
||||||
if (helpData.get(i).getTitle().toLowerCase().contains(searchTextField.getText().toLowerCase())) {
|
XMLController.setColor("000000");
|
||||||
filterData.add(helpData.get(i)); // add data from newDaten to filteredData where title contains search input
|
colorPicker.setValue(new Color(0, 0, 0, 1));
|
||||||
}
|
applyColor();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
for (int i = 0; i < filterData.size(); i++) {
|
like.setOnAction(e -> {
|
||||||
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(filterData.get(i))); // add filtered data to root node after search
|
dbController.like(getCurrentStreamUrl());
|
||||||
}
|
filmsList.set(indexList, dbController.getDatabaseFilm(getCurrentStreamUrl()));
|
||||||
if (searchTextField.getText().hashCode() == hashA) {
|
refreshTableElement();
|
||||||
XMLController.setColor("000000");
|
|
||||||
colorPicker.setValue(new Color(0, 0, 0, 1));
|
|
||||||
applyColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
like.setOnAction(new EventHandler<ActionEvent>() {
|
dislike.setOnAction(e -> {
|
||||||
@Override
|
dbController.dislike(getCurrentStreamUrl());
|
||||||
public void handle(ActionEvent event) {
|
filmsList.set(indexList, dbController.getDatabaseFilm(getCurrentStreamUrl()));
|
||||||
dbController.like(getCurrentStreamUrl());
|
refreshTableElement();
|
||||||
filmsList.set(indexList, dbController.getDatabaseFilm(getCurrentStreamUrl()));
|
|
||||||
refreshTableElement();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dislike.setOnAction(new EventHandler<ActionEvent>() {
|
// FIXME fix bug when sort by ASCENDING, wrong order
|
||||||
@Override
|
columnFavorite.sortTypeProperty().addListener((e, paramT1, paramT2) -> {
|
||||||
public void handle(ActionEvent event) {
|
filmRoot.getChildren().clear();
|
||||||
dbController.dislike(getCurrentStreamUrl());
|
filterData.clear();
|
||||||
filmsList.set(indexList, dbController.getDatabaseFilm(getCurrentStreamUrl()));
|
|
||||||
refreshTableElement();
|
if (paramT2.equals(SortType.DESCENDING)) {
|
||||||
}
|
// add favorites at the top
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FIXME fix bug when sort by ASCENDING, wrong order
|
|
||||||
*/
|
|
||||||
columnFavorite.sortTypeProperty().addListener(new ChangeListener<SortType>() {
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) {
|
|
||||||
filmRoot.getChildren().clear();
|
|
||||||
filterData.clear();
|
|
||||||
|
|
||||||
if (paramT2.equals(SortType.DESCENDING)) {
|
|
||||||
// add favorites at the top
|
|
||||||
for (FilmTabelDataType film : filmsList) {
|
|
||||||
if (film.getFavorite()) {
|
|
||||||
filterData.add(0, film);
|
|
||||||
} else {
|
|
||||||
filterData.add(film);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// add favorites at the bottom
|
|
||||||
for (FilmTabelDataType film : filmsList) {
|
|
||||||
if (!film.getFavorite()) {
|
|
||||||
filterData.add(0, film);
|
|
||||||
} else {
|
|
||||||
filterData.add(film);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addFilmsToTable(filterData);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Change-listener for treeTableViewfilm
|
|
||||||
filmsTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
|
||||||
if (filmsTreeTable.getSelectionModel().getSelectedItem() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentTableFilm = filmsTreeTable.getSelectionModel().getSelectedItem().getValue(); // set the current film object
|
|
||||||
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected items table index
|
|
||||||
for (FilmTabelDataType film : filmsList) {
|
for (FilmTabelDataType film : filmsList) {
|
||||||
if (film.equals(currentTableFilm)) {
|
if (film.getFavorite()) {
|
||||||
indexList = filmsList.indexOf(film); // get selected items list index
|
filterData.add(0, film);
|
||||||
|
} else {
|
||||||
|
filterData.add(film);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
last = indexTable - 1;
|
// add favorites at the bottom
|
||||||
next = indexTable + 1;
|
for (FilmTabelDataType film : filmsList) {
|
||||||
|
if (!film.getFavorite()) {
|
||||||
|
filterData.add(0, film);
|
||||||
if ((currentTableFilm.getCached().isAfter(lastValidCache) )|| dbController.searchCacheByURL(getCurrentStreamUrl())) {
|
} else {
|
||||||
LOGGER.info("loading from cache: " + getCurrentTitle());
|
filterData.add(film);
|
||||||
setSelectedFilmInfo(dbController.readCache(getCurrentStreamUrl()));
|
}
|
||||||
// System.out.println("cache date is: " + currentTableFilm.getCached().toString());
|
|
||||||
} else {
|
|
||||||
// System.out.println("either not cached or to old!");
|
|
||||||
// System.out.println("cache date is: " + currentTableFilm.getCached().toString());
|
|
||||||
// this is not perfect!
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
Thread omdbAPIThread = new Thread(new OMDbAPIController(dbController, currentTableFilm, XMLController.getOmdbAPIKey()));
|
|
||||||
omdbAPIThread.setName("OMDbAPI");
|
|
||||||
omdbAPIThread.start();
|
|
||||||
|
|
||||||
synchronized (omdbAPIThread) {
|
|
||||||
try {
|
|
||||||
omdbAPIThread.wait();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
LOGGER.error(e);
|
|
||||||
}
|
|
||||||
// update the GUI for the selected film
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
setSelectedFilmInfo(dbController.readCache(getCurrentStreamUrl()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addFilmsToTable(filterData);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Change-listener for treeTableViewfilm
|
||||||
|
filmsTreeTable.getSelectionModel().selectedItemProperty().addListener((e, paramT1, paramT2) -> {
|
||||||
|
if (filmsTreeTable.getSelectionModel().getSelectedItem() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentTableFilm = filmsTreeTable.getSelectionModel().getSelectedItem().getValue(); // set the current film object
|
||||||
|
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected items table index
|
||||||
|
for (FilmTabelDataType film : filmsList) {
|
||||||
|
if (film.equals(currentTableFilm)) {
|
||||||
|
indexList = filmsList.indexOf(film); // get selected items list index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
last = indexTable - 1;
|
||||||
|
next = indexTable + 1;
|
||||||
|
|
||||||
|
if ((currentTableFilm.getCached().isAfter(lastValidCache)) && dbController.searchCacheByURL(getCurrentStreamUrl())) {
|
||||||
|
LOGGER.info("loading from cache: " + getCurrentTitle());
|
||||||
|
setSelectedFilmInfo(dbController.readCache(getCurrentStreamUrl()));
|
||||||
|
} else {
|
||||||
|
// this is not perfect!
|
||||||
|
new Thread(() -> {
|
||||||
|
Thread omdbAPIThread = new Thread(new OMDbAPIController(dbController, currentTableFilm, XMLController.getOmdbAPIKey()));
|
||||||
|
omdbAPIThread.setName("OMDbAPI");
|
||||||
|
omdbAPIThread.start();
|
||||||
|
|
||||||
|
synchronized (omdbAPIThread) {
|
||||||
|
try {
|
||||||
|
omdbAPIThread.wait();
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
LOGGER.error(e1);
|
||||||
|
}
|
||||||
|
// update the GUI for the selected film
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
setSelectedFilmInfo(dbController.readCache(getCurrentStreamUrl()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Poster-Mode actions
|
// Poster-Mode actions
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table-Mode fxml actions
|
// Table-Mode fxml actions
|
||||||
@FXML
|
@FXML
|
||||||
private void playbtnclicked() {
|
private void playbtnclicked() {
|
||||||
|
@ -469,7 +426,7 @@ public class MainWindowController {
|
||||||
LOGGER.info("rootNode found, getting last watched episode");
|
LOGGER.info("rootNode found, getting last watched episode");
|
||||||
currentTableFilm = dbController.getLastWatchedEpisode(currentTableFilm.getTitle());
|
currentTableFilm = dbController.getLastWatchedEpisode(currentTableFilm.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSupportedFormat(currentTableFilm)) {
|
if (isSupportedFormat(currentTableFilm)) {
|
||||||
new Player(getCurrentTableFilm());
|
new Player(getCurrentTableFilm());
|
||||||
} else {
|
} else {
|
||||||
|
@ -491,8 +448,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
if (output.contains("which: no vlc") || output == "") {
|
if (output.contains("which: no vlc") || output == "") {
|
||||||
JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info",
|
JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info",
|
||||||
XMLController.getLocalBundle().getString("vlcNotInstalled"),
|
XMLController.getLocalBundle().getString("vlcNotInstalled"), btnStyle, primaryStage);
|
||||||
btnStyle, primaryStage);
|
|
||||||
vlcInfoAlert.showAndWait();
|
vlcInfoAlert.showAndWait();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -514,11 +470,11 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void openfolderbtnclicked() {
|
private void openfolderbtnclicked() {
|
||||||
File dest = new File(getCurrentStreamUrl()).getParentFile();
|
File dest = new File(getCurrentStreamUrl()).getParentFile();
|
||||||
|
|
||||||
if (!System.getProperty("os.name").contains("Linux")) {
|
if (!System.getProperty("os.name").contains("Linux")) {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().open(dest);
|
Desktop.getDesktop().open(dest);
|
||||||
|
@ -527,26 +483,26 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void returnBtnclicked(){
|
private void returnBtnclicked() {
|
||||||
filmsTreeTable.getSelectionModel().select(last);
|
filmsTreeTable.getSelectionModel().select(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void forwardBtnclicked(){
|
private void forwardBtnclicked() {
|
||||||
filmsTreeTable.getSelectionModel().select(next);
|
filmsTreeTable.getSelectionModel().select(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
// general fxml actions
|
// general fxml actions
|
||||||
@FXML
|
@FXML
|
||||||
private void aboutBtnAction() {
|
private void aboutBtnAction() {
|
||||||
String bodyText = "Project HomeFlix \nVersion: " + version + " (Build: " + buildNumber + ") \""
|
String bodyText = "Project HomeFlix \nVersion: " + version + " (Build: " + buildNumber + ") \"" + versionName
|
||||||
+ versionName + "\" \n" + XMLController.getLocalBundle().getString("infoText");
|
+ "\" \n" + XMLController.getLocalBundle().getString("infoText");
|
||||||
JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, btnStyle, primaryStage);
|
JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, btnStyle, primaryStage);
|
||||||
infoAlert.showAndWait();
|
infoAlert.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void settingsBtnclicked() {
|
private void settingsBtnclicked() {
|
||||||
if (settingsScrollPane.isVisible()) {
|
if (settingsScrollPane.isVisible()) {
|
||||||
|
@ -555,9 +511,9 @@ public class MainWindowController {
|
||||||
settingsScrollPane.setVisible(true);
|
settingsScrollPane.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void addDirectoryBtnAction(){
|
private void addDirectoryBtnAction() {
|
||||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||||
directoryChooser.setTitle(XMLController.getLocalBundle().getString("addDirectory"));
|
directoryChooser.setTitle(XMLController.getLocalBundle().getString("addDirectory"));
|
||||||
File selectedFolder = directoryChooser.showDialog(primaryStage);
|
File selectedFolder = directoryChooser.showDialog(primaryStage);
|
||||||
|
@ -567,9 +523,9 @@ public class MainWindowController {
|
||||||
LOGGER.error("The selected folder dosen't exist!");
|
LOGGER.error("The selected folder dosen't exist!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void addStreamSourceBtnAction(){
|
private void addStreamSourceBtnAction() {
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.setTitle(XMLController.getLocalBundle().getString("addStreamSource"));
|
fileChooser.setTitle(XMLController.getLocalBundle().getString("addStreamSource"));
|
||||||
File selectedFile = fileChooser.showOpenDialog(primaryStage);
|
File selectedFile = fileChooser.showOpenDialog(primaryStage);
|
||||||
|
@ -579,42 +535,42 @@ public class MainWindowController {
|
||||||
LOGGER.error("The selected file dosen't exist!");
|
LOGGER.error("The selected file dosen't exist!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void colorPickerAction() {
|
private void colorPickerAction() {
|
||||||
XMLController.setColor(colorPicker.getValue().toString().substring(2, 10));
|
XMLController.setColor(colorPicker.getValue().toString().substring(2, 10));
|
||||||
xmlController.saveSettings();
|
xmlController.saveSettings();
|
||||||
applyColor();
|
applyColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void updateBtnAction() {
|
private void updateBtnAction() {
|
||||||
updateController = new UpdateController(this, buildNumber, XMLController.isUseBeta());
|
updateController = new UpdateController(this, buildNumber, XMLController.isUseBeta());
|
||||||
Thread updateThread = new Thread(updateController);
|
Thread updateThread = new Thread(updateController);
|
||||||
updateThread.setName("Updater");
|
updateThread.setName("Updater");
|
||||||
updateThread.start();
|
updateThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void autoUpdateToggleBtnAction() {
|
private void autoUpdateToggleBtnAction() {
|
||||||
XMLController.setAutoUpdate(!XMLController.isAutoUpdate());
|
XMLController.setAutoUpdate(!XMLController.isAutoUpdate());
|
||||||
xmlController.saveSettings();
|
xmlController.saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void autoplayToggleBtnAction(){
|
private void autoplayToggleBtnAction() {
|
||||||
XMLController.setAutoplay(!XMLController.isAutoplay());
|
XMLController.setAutoplay(!XMLController.isAutoplay());
|
||||||
xmlController.saveSettings();
|
xmlController.saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh the selected child of the root node
|
// refresh the selected child of the root node
|
||||||
private void refreshTableElement() {
|
private void refreshTableElement() {
|
||||||
filmRoot.getChildren().get(indexTable).setValue(filmsList.get(indexList));
|
filmRoot.getChildren().get(indexTable).setValue(filmsList.get(indexList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* refresh all films in filmsList and in filmsTable
|
* refresh all films in filmsList and in filmsTable clear the FilmsList and
|
||||||
* clear the FilmsList and FilmRoot children, then update the database
|
* FilmRoot children, then update the database
|
||||||
*/
|
*/
|
||||||
private void refreshAllFilms() {
|
private void refreshAllFilms() {
|
||||||
filmsList.clear();
|
filmsList.clear();
|
||||||
|
@ -623,54 +579,74 @@ public class MainWindowController {
|
||||||
filmsList = dbController.getDatabaseFilmsList(); // returns a list of all films stored in the database
|
filmsList = dbController.getDatabaseFilmsList(); // returns a list of all films stored in the database
|
||||||
addFilmsToTable(filmsList);
|
addFilmsToTable(filmsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add data from films-list to films-table
|
* TODO rework! add data from a ObservableList to the films-table
|
||||||
|
*
|
||||||
|
* @param elementsList a list of elements you want to add
|
||||||
*/
|
*/
|
||||||
public void addFilmsToTable(ObservableList<FilmTabelDataType> elementsList) {
|
public void addFilmsToTable(ObservableList<FilmTabelDataType> elementsList) {
|
||||||
|
|
||||||
for (FilmTabelDataType element : elementsList) {
|
for (FilmTabelDataType element : elementsList) {
|
||||||
|
|
||||||
// only if the entry contains a season and a episode it's a valid series
|
// only if the entry contains a season and a episode it's a valid series
|
||||||
if (!element.getSeason().isEmpty() && !element.getEpisode().isEmpty()) {
|
if (!element.getSeason().isEmpty() && !element.getEpisode().isEmpty()) {
|
||||||
|
|
||||||
// check if there is a series node to add the item
|
// if there is any node check if it's the root node to the episode
|
||||||
for (int i = 0; i < filmRoot.getChildren().size(); i++) {
|
// else there is no node at all so we must create a new
|
||||||
if (filmRoot.getChildren().get(i).getValue().getTitle().equals(element.getTitle())) {
|
if (filmRoot.getChildren().size() > 0) {
|
||||||
// if a root node exists, add element as child
|
for (int i = 0; i < filmRoot.getChildren().size(); i++) {
|
||||||
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(
|
// if a root node exists, add element
|
||||||
element.getStreamUrl(), element.getTitle(), element.getSeason(), element.getEpisode(),
|
// else create a new root node and add the element (if rootNode is the last
|
||||||
element.getFavorite(), element.getCached(), element.getImage()));
|
// node) (works since we edit the element!)
|
||||||
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
|
if (filmRoot.getChildren().get(i).getValue().getTitle().equals(element.getTitle())) {
|
||||||
} else if (filmRoot.getChildren().get(i).nextSibling() == null) {
|
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(
|
||||||
// if no root node exists, create one and add element as child
|
new FilmTabelDataType(element.getStreamUrl(), element.getTitle(),
|
||||||
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(new FilmTabelDataType(
|
element.getSeason(), element.getEpisode(), element.getFavorite(),
|
||||||
element.getTitle() + "_rootNode", element.getTitle(), "", "", element.getFavorite(),
|
element.getCached(), element.getImage()));
|
||||||
element.getCached() , element.getImage()));
|
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
|
||||||
filmRoot.getChildren().add(seriesRootNode);
|
} else if (filmRoot.getChildren().get(i).nextSibling() == null) {
|
||||||
|
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(
|
||||||
|
new FilmTabelDataType(element.getTitle() + "_rootNode", element.getTitle(), "", "",
|
||||||
|
element.getFavorite(), element.getCached(), element.getImage()));
|
||||||
|
filmRoot.getChildren().add(seriesRootNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// add new root node
|
||||||
|
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(
|
||||||
|
new FilmTabelDataType(element.getTitle() + "_rootNode", element.getTitle(), "", "",
|
||||||
|
element.getFavorite(), element.getCached(), element.getImage()));
|
||||||
|
filmRoot.getChildren().add(seriesRootNode);
|
||||||
|
|
||||||
|
// add new element
|
||||||
|
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(
|
||||||
|
element.getStreamUrl(), element.getTitle(), element.getSeason(), element.getEpisode(),
|
||||||
|
element.getFavorite(), element.getCached(), element.getImage()));
|
||||||
|
filmRoot.getChildren().get(0).getChildren().add(episodeNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if season and episode are empty, we can assume the object is a film
|
// if season and episode are empty, we can assume the object is a film
|
||||||
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(element));
|
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a all elements of sourcesList to the sources table on the settings pane
|
// add a all elements of sourcesList to the sources table on the settings pane
|
||||||
public void addSourceToTable() {
|
public void addSourceToTable() {
|
||||||
for (SourceDataType source: sourcesList) {
|
for (SourceDataType source : sourcesList) {
|
||||||
sourceRoot.getChildren().add(new TreeItem<SourceDataType>(source)); // add data to root-node
|
sourceRoot.getChildren().add(new TreeItem<SourceDataType>(source)); // add data to root-node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a source to the newsources list
|
* add a source to the newsources list
|
||||||
|
*
|
||||||
* @param path to the source
|
* @param path to the source
|
||||||
* @param mode of the source (local or streaming)
|
* @param mode of the source (local or streaming)
|
||||||
*/
|
*/
|
||||||
public void addSource(String path, String mode) {
|
public void addSource(String path, String mode) {
|
||||||
JsonObject source = null;
|
|
||||||
JsonArray newsources = null;
|
JsonArray newsources = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -683,7 +659,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new source
|
// add new source
|
||||||
source = Json.object().add("path", path).add("mode", mode);
|
JsonObject source = Json.object().add("path", path).add("mode", mode);
|
||||||
newsources.add(source);
|
newsources.add(source);
|
||||||
Writer writer = new FileWriter(XMLController.getDirHomeFlix() + "/sources.json");
|
Writer writer = new FileWriter(XMLController.getDirHomeFlix() + "/sources.json");
|
||||||
newsources.writeTo(writer);
|
newsources.writeTo(writer);
|
||||||
|
@ -691,20 +667,18 @@ public class MainWindowController {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear old sources list/table
|
// clear old sources list/table
|
||||||
getSourcesList().clear();
|
getSourcesList().clear();
|
||||||
sourceRoot.getChildren().clear();
|
sourceRoot.getChildren().clear();
|
||||||
|
|
||||||
// clear the FilmsList and FilmRoot children, then update the database
|
refreshAllFilms(); // refresh the FilmsList
|
||||||
refreshAllFilms();
|
|
||||||
|
|
||||||
checkAllPosters(); // check if there is anything to cache
|
checkAllPosters(); // check if there is anything to cache
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the color of the GUI-Elements
|
* set the color of the GUI-Elements if usedColor is less than checkColor set
|
||||||
* if usedColor is less than checkColor set text fill white, else black
|
* text fill white, else black
|
||||||
*/
|
*/
|
||||||
private void applyColor() {
|
private void applyColor() {
|
||||||
String menuBtnStyle;
|
String menuBtnStyle;
|
||||||
|
@ -712,32 +686,34 @@ public class MainWindowController {
|
||||||
BigInteger checkColor = new BigInteger("78909cff", 16);
|
BigInteger checkColor = new BigInteger("78909cff", 16);
|
||||||
|
|
||||||
if (usedColor.compareTo(checkColor) == -1) {
|
if (usedColor.compareTo(checkColor) == -1) {
|
||||||
btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: WHITE;";
|
btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor()
|
||||||
|
+ "; -fx-text-fill: WHITE;";
|
||||||
menuBtnStyle = "-fx-text-fill: WHITE;";
|
menuBtnStyle = "-fx-text-fill: WHITE;";
|
||||||
|
|
||||||
playbtn.setGraphic(new ImageView(new Image("icons/ic_play_arrow_white_18dp_1x.png")));
|
playbtn.setGraphic(new ImageView(new Image("icons/ic_play_arrow_white_18dp_1x.png")));
|
||||||
returnBtn.setGraphic(new ImageView(new Image("icons/ic_skip_previous_white_18dp_1x.png")));
|
returnBtn.setGraphic(new ImageView(new Image("icons/ic_skip_previous_white_18dp_1x.png")));
|
||||||
forwardBtn.setGraphic(new ImageView(new Image("icons/ic_skip_next_white_18dp_1x.png")));
|
forwardBtn.setGraphic(new ImageView(new Image("icons/ic_skip_next_white_18dp_1x.png")));
|
||||||
|
|
||||||
menuHam.getStyleClass().clear();
|
menuHam.getStyleClass().clear();
|
||||||
menuHam.getStyleClass().add("jfx-hamburgerW");
|
menuHam.getStyleClass().add("jfx-hamburgerW");
|
||||||
} else {
|
} else {
|
||||||
btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: BLACK;";
|
btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor()
|
||||||
|
+ "; -fx-text-fill: BLACK;";
|
||||||
menuBtnStyle = "-fx-text-fill: BLACK;";
|
menuBtnStyle = "-fx-text-fill: BLACK;";
|
||||||
|
|
||||||
playbtn.setGraphic(new ImageView(new Image("icons/ic_play_arrow_black_18dp_1x.png")));
|
playbtn.setGraphic(new ImageView(new Image("icons/ic_play_arrow_black_18dp_1x.png")));
|
||||||
returnBtn.setGraphic(new ImageView(new Image("icons/ic_skip_previous_black_18dp_1x.png")));
|
returnBtn.setGraphic(new ImageView(new Image("icons/ic_skip_previous_black_18dp_1x.png")));
|
||||||
forwardBtn.setGraphic(new ImageView(new Image("icons/ic_skip_next_black_18dp_1x.png")));
|
forwardBtn.setGraphic(new ImageView(new Image("icons/ic_skip_next_black_18dp_1x.png")));
|
||||||
|
|
||||||
menuHam.getStyleClass().clear();
|
menuHam.getStyleClass().clear();
|
||||||
menuHam.getStyleClass().add("jfx-hamburgerB");
|
menuHam.getStyleClass().add("jfx-hamburgerB");
|
||||||
}
|
}
|
||||||
|
|
||||||
// boxes and TextFields
|
// boxes and TextFields
|
||||||
sideMenuVBox.setStyle("-fx-background-color: #" + XMLController.getColor() + ";");
|
sideMenuVBox.setStyle("-fx-background-color: #" + XMLController.getColor() + ";");
|
||||||
topHBox.setStyle("-fx-background-color: #" + XMLController.getColor() + ";");
|
topHBox.setStyle("-fx-background-color: #" + XMLController.getColor() + ";");
|
||||||
searchTextField.setFocusColor(Color.valueOf(XMLController.getColor()));
|
searchTextField.setFocusColor(Color.valueOf(XMLController.getColor()));
|
||||||
|
|
||||||
// normal buttons
|
// normal buttons
|
||||||
addDirectoryBtn.setStyle(btnStyle);
|
addDirectoryBtn.setStyle(btnStyle);
|
||||||
addStreamSourceBtn.setStyle(btnStyle);
|
addStreamSourceBtn.setStyle(btnStyle);
|
||||||
|
@ -746,12 +722,12 @@ public class MainWindowController {
|
||||||
openfolderbtn.setStyle(btnStyle);
|
openfolderbtn.setStyle(btnStyle);
|
||||||
returnBtn.setStyle(btnStyle);
|
returnBtn.setStyle(btnStyle);
|
||||||
forwardBtn.setStyle(btnStyle);
|
forwardBtn.setStyle(btnStyle);
|
||||||
|
|
||||||
// menu buttons
|
// menu buttons
|
||||||
settingsBtn.setStyle(menuBtnStyle);
|
settingsBtn.setStyle(menuBtnStyle);
|
||||||
aboutBtn.setStyle(menuBtnStyle);
|
aboutBtn.setStyle(menuBtnStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// slide in in 400ms
|
// slide in in 400ms
|
||||||
private void sideMenuSlideIn() {
|
private void sideMenuSlideIn() {
|
||||||
sideMenuVBox.setVisible(true);
|
sideMenuVBox.setVisible(true);
|
||||||
|
@ -760,7 +736,7 @@ public class MainWindowController {
|
||||||
translateTransition.setToX(0);
|
translateTransition.setToX(0);
|
||||||
translateTransition.play();
|
translateTransition.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
// slide out in 400ms
|
// slide out in 400ms
|
||||||
private void sideMenuSlideOut() {
|
private void sideMenuSlideOut() {
|
||||||
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox);
|
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox);
|
||||||
|
@ -768,7 +744,7 @@ public class MainWindowController {
|
||||||
translateTransition.setToX(-150);
|
translateTransition.setToX(-150);
|
||||||
translateTransition.play();
|
translateTransition.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the local based on the languageChoisBox selection
|
* set the local based on the languageChoisBox selection
|
||||||
*/
|
*/
|
||||||
|
@ -807,11 +783,11 @@ public class MainWindowController {
|
||||||
columnSeason.setText(XMLController.getLocalBundle().getString("columnSeason"));
|
columnSeason.setText(XMLController.getLocalBundle().getString("columnSeason"));
|
||||||
columnEpisode.setText(XMLController.getLocalBundle().getString("columnEpisode"));
|
columnEpisode.setText(XMLController.getLocalBundle().getString("columnEpisode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSelectedFilmInfo(String[] cacheData) {
|
private void setSelectedFilmInfo(String[] cacheData) {
|
||||||
Font font = Font.font("System", FontWeight.BOLD, (int) Math.round(XMLController.getFontSize()));
|
Font font = Font.font("System", FontWeight.BOLD, (int) Math.round(XMLController.getFontSize()));
|
||||||
ObservableList<Node> textFlow = getTextFlow().getChildren();
|
ObservableList<Node> textFlow = getTextFlow().getChildren();
|
||||||
|
|
||||||
// TODO this should move! ***
|
// TODO this should move! ***
|
||||||
Text[] nameText = new Text[20];
|
Text[] nameText = new Text[20];
|
||||||
nameText[0] = new Text(XMLController.getLocalBundle().getString("title") + ": ");
|
nameText[0] = new Text(XMLController.getLocalBundle().getString("title") + ": ");
|
||||||
|
@ -836,23 +812,23 @@ public class MainWindowController {
|
||||||
nameText[19] = new Text(XMLController.getLocalBundle().getString("website") + ": ");
|
nameText[19] = new Text(XMLController.getLocalBundle().getString("website") + ": ");
|
||||||
// ***
|
// ***
|
||||||
|
|
||||||
// set the correct font for the nameText
|
// set the correct font for the nameText
|
||||||
for (Text text : nameText) {
|
for (Text text : nameText) {
|
||||||
text.setFont(font);
|
text.setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the textFlow and add the new text
|
// clear the textFlow and add the new text
|
||||||
textFlow.clear();
|
textFlow.clear();
|
||||||
|
|
||||||
// TODO rework
|
// TODO rework
|
||||||
for(int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
if (cacheData[i] != null && (i == 5 || i == 6) && cacheData[5].length() == 0) {
|
if (cacheData[i] != null && (i == 5 || i == 6) && cacheData[5].length() == 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if(cacheData[i] != null){
|
} else if (cacheData[i] != null) {
|
||||||
textFlow.addAll(nameText[i], new Text(cacheData[i] + "\n"));
|
textFlow.addAll(nameText[i], new Text(cacheData[i] + "\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getTextFlow().setStyle("-fx-font-size : " + ((int) Math.round(XMLController.getFontSize()) + 1) + "px;");
|
getTextFlow().setStyle("-fx-font-size : " + ((int) Math.round(XMLController.getFontSize()) + 1) + "px;");
|
||||||
|
|
||||||
// add the image
|
// add the image
|
||||||
|
@ -867,7 +843,7 @@ public class MainWindowController {
|
||||||
posterImageView.setImage(new Image(cacheData[20]));
|
posterImageView.setImage(new Image(cacheData[20]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if AutoUpdate, then check for updates
|
// if AutoUpdate, then check for updates
|
||||||
private void checkAutoUpdate() {
|
private void checkAutoUpdate() {
|
||||||
|
|
||||||
|
@ -884,49 +860,50 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if a film is supported by the HomeFlixPlayer or not
|
* check if a film is supported by the HomeFlixPlayer or not this is the case if
|
||||||
* this is the case if the mime type is mp4
|
* the mime type is mp4
|
||||||
|
*
|
||||||
* @param entry the film you want to check
|
* @param entry the film you want to check
|
||||||
* @return true if so, false if not
|
* @return true if so, false if not
|
||||||
*/
|
*/
|
||||||
private boolean isSupportedFormat(FilmTabelDataType film) {
|
private boolean isSupportedFormat(FilmTabelDataType film) {
|
||||||
String mimeType = URLConnection.guessContentTypeFromName(film.getStreamUrl());
|
String mimeType = URLConnection.guessContentTypeFromName(film.getStreamUrl());
|
||||||
return mimeType != null && (mimeType.contains("mp4") || mimeType.contains("vp6"));
|
return mimeType != null && (mimeType.contains("mp4") || mimeType.contains("vp6"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Poser Mode WIP
|
* Poser Mode WIP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void posterModeStartup() {
|
private void posterModeStartup() {
|
||||||
checkAllPosters();
|
checkAllPosters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if all posters are cached, if not cache the missing ones
|
* check if all posters are cached, if not cache the missing ones
|
||||||
*/
|
*/
|
||||||
private void checkAllPosters() {
|
private void checkAllPosters() {
|
||||||
// get all not cached entries, none of them should have a cached poster
|
// get all not cached entries, none of them should have a cached poster
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||||
|
|
||||||
for (FilmTabelDataType entry : dbController.getAllNotCachedEntries()) {
|
for (FilmTabelDataType entry : dbController.getAllNotCachedEntries()) {
|
||||||
System.out.println(entry.getStreamUrl() + " is NOT cached!");
|
System.out.println(entry.getStreamUrl() + " is NOT cached!");
|
||||||
|
|
||||||
Runnable OMDbAPIWorker = new OMDbAPIController(dbController, entry, XMLController.getOmdbAPIKey());
|
Runnable OMDbAPIWorker = new OMDbAPIController(dbController, entry, XMLController.getOmdbAPIKey());
|
||||||
executor.execute(OMDbAPIWorker);
|
executor.execute(OMDbAPIWorker);
|
||||||
}
|
}
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
|
|
||||||
// TODO show loading screen
|
// TODO show loading screen
|
||||||
|
|
||||||
// update all elements from the database
|
// update all elements from the database
|
||||||
refreshAllFilms();
|
refreshAllFilms();
|
||||||
}
|
}
|
||||||
|
|
||||||
// getter and setter
|
// getter and setter
|
||||||
|
|
||||||
public FilmTabelDataType getCurrentTableFilm() {
|
public FilmTabelDataType getCurrentTableFilm() {
|
||||||
return currentTableFilm;
|
return currentTableFilm;
|
||||||
}
|
}
|
||||||
|
@ -942,7 +919,7 @@ public class MainWindowController {
|
||||||
public int getIndexTable() {
|
public int getIndexTable() {
|
||||||
return indexTable;
|
return indexTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndexList() {
|
public int getIndexList() {
|
||||||
return indexList;
|
return indexList;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue