Browse Source

removed more mwc dependencies & code clean up

pull/12/head
Jannik 4 years ago
parent
commit
291f183f5e
  1. 64
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java
  2. 2
      src/main/java/kellerkinder/HomeFlix/controller/DBController.java
  3. 8
      src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java
  4. 16
      src/main/java/kellerkinder/HomeFlix/controller/XMLController.java
  5. 9
      src/main/java/kellerkinder/HomeFlix/player/Player.java
  6. 14
      src/main/java/kellerkinder/HomeFlix/player/PlayerController.java
  7. 10
      src/main/resources/fxml/MainWindow.fxml

64
src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java

@ -132,17 +132,19 @@ public class MainWindowController {
@FXML private TableColumn<SourceDataType, String> sourceColumn;
@FXML private TableColumn<SourceDataType, String> modeColumn;
@FXML private TreeTableColumn<FilmTabelDataType, String> columnStreamUrl;
@FXML private TreeTableColumn<FilmTabelDataType, String> columnTitle;
@FXML private TreeTableColumn<FilmTabelDataType, ImageView> columnFavorite;
@FXML private TreeTableColumn<FilmTabelDataType, String> columnSeason;
@FXML private TreeTableColumn<FilmTabelDataType, String> columnEpisode;
// table-mode
@FXML private AnchorPane tableModeAnchorPane;
@FXML private JFXTextField searchTextField;
@FXML private TreeTableView<FilmTabelDataType> filmsTreeTable;
@FXML private TreeItem<FilmTabelDataType> filmRoot = new TreeItem<>(new FilmTabelDataType("", "", "", "", false, false, null));
@FXML private TreeTableColumn<FilmTabelDataType, String> columnStreamUrl = new TreeTableColumn<>("File Name");
@FXML private TreeTableColumn<FilmTabelDataType, String> columnTitle = new TreeTableColumn<>("Title");
@FXML private TreeTableColumn<FilmTabelDataType, String> columnSeason = new TreeTableColumn<>("Season");
@FXML private TreeTableColumn<FilmTabelDataType, String> columnEpisode = new TreeTableColumn<>("Episode");
@FXML private TreeTableColumn<FilmTabelDataType, ImageView> columnFavorite = new TreeTableColumn<>("Favorite");
@FXML private ScrollPane textScrollPane;
@FXML private TextFlow textFlow;
@ -156,9 +158,8 @@ public class MainWindowController {
// poster-mode
// @FXML private AnchorPane posterModeAnchorPane;
private MainWindowController mainWindowController;
private static DBController dbController; // the player needs the initialized dbController
private UpdateController updateController;
private DBController dbController;
private XMLController xmlController;
private Stage primaryStage;
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
@ -182,7 +183,7 @@ public class MainWindowController {
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
private ObservableList<FilmTabelDataType> filterData = FXCollections.observableArrayList();
private ObservableList<FilmTabelDataType> filmsList = FXCollections.observableArrayList();
private ObservableList<SourceDataType> sourcesList = FXCollections.observableArrayList();
private static ObservableList<SourceDataType> sourcesList = FXCollections.observableArrayList();
private MenuItem like = new MenuItem("like");
private MenuItem dislike = new MenuItem("dislike"); // TODO one option (like or dislike)
private ContextMenu menu = new ContextMenu(like, dislike);
@ -193,7 +194,6 @@ public class MainWindowController {
@FXML
public void initialize() {
mainWindowController = this;
xmlController = new XMLController();
dbController = new DBController(this);
}
@ -211,6 +211,9 @@ public class MainWindowController {
initActions();
dbController.init();
// load sources list in gui
addSourceToTable();
// posterModeStartup(); // TODO testing DO NOT USE THIS!!
}
@ -243,24 +246,6 @@ public class MainWindowController {
private void initTabel() {
// film Table
columnStreamUrl.setMaxWidth(0);
columnTitle.setMaxWidth(182);
columnFavorite.setMaxWidth(80);
columnSeason.setMaxWidth(70);
columnEpisode.setMaxWidth(70);
columnTitle.setMinWidth(182);
columnFavorite.setMinWidth(80);
columnSeason.setMinWidth(70);
columnEpisode.setMinWidth(70);
columnTitle.setResizable(false);
columnFavorite.setResizable(false);
columnSeason.setResizable(false);
columnEpisode.setResizable(false);
columnFavorite.setStyle("-fx-alignment: CENTER;");
filmsTreeTable.setRoot(filmRoot);
filmsTreeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
filmsTreeTable.setShowRoot(false);
@ -272,14 +257,6 @@ public class MainWindowController {
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty());
columnFavorite.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
// add columns to treeTableViewfilm
filmsTreeTable.getColumns().add(columnStreamUrl);
filmsTreeTable.getColumns().add(columnTitle);
filmsTreeTable.getColumns().add(columnFavorite);
filmsTreeTable.getColumns().add(columnSeason);
filmsTreeTable.getColumns().add(columnEpisode);
filmsTreeTable.getColumns().get(0).setVisible(false); // hide columnStreamUrl (important)
// context menu for treeTableViewfilm
filmsTreeTable.setContextMenu(menu);
@ -467,7 +444,7 @@ public class MainWindowController {
}
if (isSupportedFormat(currentTableFilm)) {
new Player(mainWindowController);
new Player(getCurrentTableFilm());
} else {
LOGGER.error("using fallback player!");
if (System.getProperty("os.name").contains("Linux")) {
@ -641,10 +618,11 @@ public class MainWindowController {
}
}
// add a source to the sources table on the settings pane
public void addSourceToTable(String path, String mode) {
sourcesList.add(new SourceDataType(path, mode));
sourceRoot.getChildren().add(new TreeItem<SourceDataType>(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node
// add a all elements of sourcesList to the sources table on the settings pane
public void addSourceToTable() {
for (SourceDataType source: sourcesList) {
sourceRoot.getChildren().add(new TreeItem<SourceDataType>(source)); // add data to root-node
}
}
/**
@ -785,9 +763,9 @@ public class MainWindowController {
branchLbl.setText(XMLController.getLocalBundle().getString("branchLbl"));
columnStreamUrl.setText(XMLController.getLocalBundle().getString("columnStreamUrl"));
columnTitle.setText(XMLController.getLocalBundle().getString("columnName"));
columnFavorite.setText(XMLController.getLocalBundle().getString("columnFavorite"));
columnSeason.setText(XMLController.getLocalBundle().getString("columnSeason"));
columnEpisode.setText(XMLController.getLocalBundle().getString("columnEpisode"));
columnFavorite.setText(XMLController.getLocalBundle().getString("columnFavorite"));
}
// if AutoUpdate, then check for updates
@ -841,7 +819,7 @@ public class MainWindowController {
}
// getter and setter
public DBController getDbController() {
public static DBController getDbController() {
return dbController;
}
@ -869,7 +847,7 @@ public class MainWindowController {
return filmsList;
}
public ObservableList<SourceDataType> getSourcesList() {
public static ObservableList<SourceDataType> getSourcesList() {
return sourcesList;
}

2
src/main/java/kellerkinder/HomeFlix/controller/DBController.java

@ -143,7 +143,7 @@ public class DBController {
* load all sources
*/
private void loadSources() {
SourcesController sourcesController = new SourcesController(mainWindowController);
SourcesController sourcesController = new SourcesController();
sourceStreams = sourcesController.loadSources();
}

8
src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java

@ -39,15 +39,15 @@ import com.eclipsesource.json.JsonValue;
import kellerkinder.HomeFlix.application.MainWindowController;
import kellerkinder.HomeFlix.datatypes.DatabaseDataType;
import kellerkinder.HomeFlix.datatypes.SourceDataType;
public class SourcesController {
private MainWindowController mainWindowController;
private List<DatabaseDataType> sourceStreams = new ArrayList<DatabaseDataType>();
private static final Logger LOGGER = LogManager.getLogger(SourcesController.class.getName());
public SourcesController(MainWindowController mainWindowController) {
this.mainWindowController = mainWindowController;
public SourcesController() {
// Auto-generated constructor stub
}
/**
@ -61,7 +61,7 @@ public class SourcesController {
for (JsonValue source : sources) {
String path = source.asObject().getString("path", "");
String mode = source.asObject().getString("mode", "");
mainWindowController.addSourceToTable(path, mode); // add loaded source to source-table TODO this should be done in mwc
MainWindowController.getSourcesList().add(new SourceDataType(path, mode));
if (mode.equals("local"))
addLocalSource(path);

16
src/main/java/kellerkinder/HomeFlix/controller/XMLController.java

@ -42,14 +42,14 @@ import com.eclipsesource.json.JsonObject;
public class XMLController {
private static String userHome = System.getProperty("user.home");
private static String userName = System.getProperty("user.name");
private static String osName = System.getProperty("os.name");
private static String osArch = System.getProperty("os.arch");
private static String osVers = System.getProperty("os.version");
private static String javaVers = System.getProperty("java.version");
private static String javaVend = System.getProperty("java.vendor");
private static String sysLocal = System.getProperty("user.language") + "_" + System.getProperty("user.country");
private static final String userHome = System.getProperty("user.home");
private static final String userName = System.getProperty("user.name");
private static final String osName = System.getProperty("os.name");
private static final String osArch = System.getProperty("os.arch");
private static final String osVers = System.getProperty("os.version");
private static final String javaVers = System.getProperty("java.version");
private static final String javaVend = System.getProperty("java.vendor");
private static final String sysLocal = System.getProperty("user.language") + "_" + System.getProperty("user.country");
private static String dirHomeFlixPath;
private static File dirHomeFlix;
private static File configFile;

9
src/main/java/kellerkinder/HomeFlix/player/Player.java

@ -31,6 +31,7 @@ import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import kellerkinder.HomeFlix.application.Main;
import kellerkinder.HomeFlix.application.MainWindowController;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
public class Player {
@ -41,10 +42,10 @@ public class Player {
/**
* generate a new PlayerWindow
* @param mainWindowController the MainWindowController
* @param currentTableFilm the currently selected film
*/
public Player(MainWindowController mainWindowController) {
playerController = new PlayerController(mainWindowController, this, mainWindowController.getCurrentTableFilm());
public Player(FilmTabelDataType currentTableFilm) {
playerController = new PlayerController(this, currentTableFilm);
try {
FXMLLoader fxmlLoader = new FXMLLoader();
@ -58,7 +59,7 @@ public class Player {
stage.getIcons().add(new Image(Main.class.getResourceAsStream("/icons/Homeflix_Icon_64x64.png")));
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
mainWindowController.getDbController().setCurrentTime(mainWindowController.getCurrentStreamUrl(),
MainWindowController.getDbController().setCurrentTime(currentTableFilm.getStreamUrl(),
playerController.getCurrentTime());
playerController.getMediaPlayer().stop();
stage.close();

14
src/main/java/kellerkinder/HomeFlix/player/PlayerController.java

@ -67,7 +67,6 @@ public class PlayerController {
@FXML private JFXButton nextEpBtn;
private Player player;
private MainWindowController mainWCon;
private Media media;
private MediaPlayer mediaPlayer;
@ -95,8 +94,7 @@ public class PlayerController {
* @param player the player object (needed for closing action)
* @param film the film object
*/
public PlayerController(MainWindowController mainWCon, Player player, FilmTabelDataType film) {
this.mainWCon = mainWCon;
public PlayerController(Player player, FilmTabelDataType film) {
this.player = player;
this.film = film;
}
@ -124,7 +122,7 @@ public class PlayerController {
width.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width"));
height.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height"));
startTime = mainWCon.getDbController().getCurrentTime(film.getStreamUrl());
startTime = MainWindowController.getDbController().getCurrentTime(film.getStreamUrl());
autoplay = XMLController.isAutoplay();
season = !film.getSeason().isEmpty() ? Integer.parseInt(film.getSeason()) : 0;
episode = !film.getEpisode().isEmpty() ? Integer.parseInt(film.getEpisode()) : 0;
@ -177,7 +175,7 @@ public class PlayerController {
} else if (timeToEnd < 120) {
// if we are 120ms to the end stop the media
mediaPlayer.stop();
mainWCon.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
MainWindowController.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
playBtn.setGraphic(play_arrow_black);
} else {
if (nextEpBtn.isVisible())
@ -255,7 +253,7 @@ public class PlayerController {
@FXML
void stopBtnAction(ActionEvent event) {
mainWCon.getDbController().setCurrentTime(film.getStreamUrl(), currentTime);
MainWindowController.getDbController().setCurrentTime(film.getStreamUrl(), currentTime);
mediaPlayer.stop();
player.getStage().close();
}
@ -289,8 +287,8 @@ public class PlayerController {
private void autoPlayNewFilm() {
autoplay = false;
mainWCon.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
FilmTabelDataType nextFilm = mainWCon.getDbController().getNextEpisode(film.getTitle(), episode, season);
MainWindowController.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
FilmTabelDataType nextFilm = MainWindowController.getDbController().getNextEpisode(film.getTitle(), episode, season);
if (nextFilm != null) {
mediaPlayer.stop();
film = nextFilm;

10
src/main/resources/fxml/MainWindow.fxml

@ -13,6 +13,7 @@
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TreeTableColumn?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
@ -31,7 +32,14 @@
<Font name="Arial" size="12.0" />
</font>
</JFXTextField>
<TreeTableView fx:id="filmsTreeTable" prefHeight="500.0" prefWidth="420.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="56.0" />
<TreeTableView fx:id="filmsTreeTable" prefHeight="500.0" prefWidth="420.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="56.0">
<columns>
<TreeTableColumn fx:id="columnStreamUrl" editable="false" prefWidth="75.0" resizable="false" text="Stream URL" visible="false" />
<TreeTableColumn fx:id="columnTitle" maxWidth="182.0" minWidth="182.0" prefWidth="182.0" resizable="false" text="Title" />
<TreeTableColumn fx:id="columnFavorite" maxWidth="80.0" minWidth="80.0" resizable="false" style="-fx-alignment: CENTER;" text="Favorite" />
<TreeTableColumn fx:id="columnSeason" maxWidth="70.0" minWidth="70.0" prefWidth="70.0" resizable="false" text="Season" />
<TreeTableColumn fx:id="columnEpisode" maxWidth="70.0" minWidth="70.0" prefWidth="70.0" resizable="false" text="Episode" />
</columns></TreeTableView>
<ScrollPane fx:id="textScrollPane" fitToWidth="true" prefHeight="544.0" prefWidth="320.0" AnchorPane.bottomAnchor="12.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="12.0">
<content>
<TextFlow fx:id="textFlow" accessibleRole="TEXT_AREA" maxHeight="544.0" maxWidth="320.0" visible="true" />

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close