From 834bffda93a7d95948d655d69f7f084b9c69628c Mon Sep 17 00:00:00 2001 From: Seil0 Date: Fri, 22 May 2020 17:12:07 +0200 Subject: [PATCH] clean up DetailViews --- .../application/MainWindowController.java | 2 + .../homeflix/application/SettingsView.java | 1 + .../homeflix/application/view/DetailView.java | 42 +++++++++++++++++ .../{ => view}/FilmDetailView.java | 47 ++----------------- .../{ => view}/SeriesDetailView.java | 36 ++------------ src/main/resources/fxml/FilmDetailView.fxml | 2 +- src/main/resources/fxml/SeriesDetailView.fxml | 2 +- 7 files changed, 56 insertions(+), 76 deletions(-) create mode 100644 src/main/java/org/mosad/homeflix/application/view/DetailView.java rename src/main/java/org/mosad/homeflix/application/{ => view}/FilmDetailView.java (85%) rename src/main/java/org/mosad/homeflix/application/{ => view}/SeriesDetailView.java (88%) diff --git a/src/main/java/org/mosad/homeflix/application/MainWindowController.java b/src/main/java/org/mosad/homeflix/application/MainWindowController.java index 00e9bd2..10125d5 100644 --- a/src/main/java/org/mosad/homeflix/application/MainWindowController.java +++ b/src/main/java/org/mosad/homeflix/application/MainWindowController.java @@ -39,6 +39,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kellerkinder.Alerts.JFX2BtnCancelAlert; import org.kellerkinder.Alerts.JFXInfoAlert; +import org.mosad.homeflix.application.view.FilmDetailView; +import org.mosad.homeflix.application.view.SeriesDetailView; import org.mosad.homeflix.controller.DBController; import org.mosad.homeflix.controller.OMDbAPIController; import org.mosad.homeflix.controller.UpdateController; diff --git a/src/main/java/org/mosad/homeflix/application/SettingsView.java b/src/main/java/org/mosad/homeflix/application/SettingsView.java index b44541a..0f29967 100644 --- a/src/main/java/org/mosad/homeflix/application/SettingsView.java +++ b/src/main/java/org/mosad/homeflix/application/SettingsView.java @@ -30,6 +30,7 @@ import java.io.Writer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.mosad.homeflix.application.view.FilmDetailView; import org.mosad.homeflix.controller.DBController; import org.mosad.homeflix.controller.UpdateController; import org.mosad.homeflix.controller.XMLController; diff --git a/src/main/java/org/mosad/homeflix/application/view/DetailView.java b/src/main/java/org/mosad/homeflix/application/view/DetailView.java new file mode 100644 index 0000000..d944263 --- /dev/null +++ b/src/main/java/org/mosad/homeflix/application/view/DetailView.java @@ -0,0 +1,42 @@ +package org.mosad.homeflix.application.view; + +import org.mosad.homeflix.application.MainWindowController; + +import javafx.animation.FadeTransition; +import javafx.fxml.FXML; +import javafx.scene.layout.AnchorPane; +import javafx.util.Duration; + +public class DetailView { + + @FXML protected AnchorPane rootPane; + + public void updateGUILocal() { + throw new UnsupportedOperationException(); + } + /** + * show the root pane + */ + public void showPane() { + rootPane.setVisible(true); + FadeTransition fadeIn = new FadeTransition(Duration.millis(300), rootPane); + fadeIn.setFromValue(0.3); + fadeIn.setToValue(1.0); + fadeIn.play(); + } + + /** + * hide the root pane and disable the blur in MainWindowController + */ + protected void hidePane() { + FadeTransition fadeOut = new FadeTransition(Duration.millis(200), rootPane); + fadeOut.setFromValue(1.0); + fadeOut.setToValue(0.3); + fadeOut.play(); + + rootPane.setVisible(false); + + MainWindowController.getInstance().disableBlur(); // disable blur + } + +} diff --git a/src/main/java/org/mosad/homeflix/application/FilmDetailView.java b/src/main/java/org/mosad/homeflix/application/view/FilmDetailView.java similarity index 85% rename from src/main/java/org/mosad/homeflix/application/FilmDetailView.java rename to src/main/java/org/mosad/homeflix/application/view/FilmDetailView.java index a4d9c37..06f8bb1 100644 --- a/src/main/java/org/mosad/homeflix/application/FilmDetailView.java +++ b/src/main/java/org/mosad/homeflix/application/view/FilmDetailView.java @@ -20,7 +20,7 @@ * */ -package org.mosad.homeflix.application; +package org.mosad.homeflix.application.view; import java.awt.Desktop; import java.io.File; @@ -35,18 +35,13 @@ import org.mosad.homeflix.player.Player; import com.jfoenix.controls.JFXButton; -import javafx.animation.FadeTransition; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; import javafx.scene.text.Text; -import javafx.util.Duration; -public class FilmDetailView { - - @FXML private AnchorPane filmDVPane; +public class FilmDetailView extends DetailView { @FXML private Label lblTitle; @FXML private Label lblYear; @@ -88,7 +83,7 @@ public class FilmDetailView { public void initialize() { dbController = DBController.getInstance(); - filmDVPane.setStyle("-fx-background-color: rgba(89,89,89,0.9);"); + rootPane.setStyle("-fx-background-color: rgba(89,89,89,0.9);"); } @FXML @@ -115,7 +110,7 @@ public class FilmDetailView { @FXML private void btnPlayAction() { - playFilm(); + new Player(currentStreamURL); } @FXML @@ -178,6 +173,7 @@ public class FilmDetailView { /** * update the text of all static GUI elements of FilmDeatilView */ + @Override public void updateGUILocal() { lblCrew.setText(XMLController.getLocalBundle().getString("crew")); lblDirectorsInfo.setText(XMLController.getLocalBundle().getString("directors")); @@ -190,38 +186,5 @@ public class FilmDetailView { lblRevenueInfo.setText(XMLController.getLocalBundle().getString("boxOffice")); lblRatingInfo.setText(XMLController.getLocalBundle().getString("rated")); } - - /** - * show the FilmDVpane - */ - public void showPane() { - filmDVPane.setVisible(true); - FadeTransition fadeIn = new FadeTransition(Duration.millis(300), filmDVPane); - fadeIn.setFromValue(0.3); - fadeIn.setToValue(1.0); - fadeIn.play(); - } - - /** - * hide the FilmDVpane - */ - private void hidePane() { - FadeTransition fadeOut = new FadeTransition(Duration.millis(200), filmDVPane); - fadeOut.setFromValue(1.0); - fadeOut.setToValue(0.3); - fadeOut.play(); - - filmDVPane.setVisible(false); - - MainWindowController.getInstance().disableBlur(); // disable blur - } - - private void playFilm() { - if(new File(currentStreamURL).isDirectory()) { - return; - } - - new Player(currentStreamURL); - } } diff --git a/src/main/java/org/mosad/homeflix/application/SeriesDetailView.java b/src/main/java/org/mosad/homeflix/application/view/SeriesDetailView.java similarity index 88% rename from src/main/java/org/mosad/homeflix/application/SeriesDetailView.java rename to src/main/java/org/mosad/homeflix/application/view/SeriesDetailView.java index a1c3a53..9da00e8 100644 --- a/src/main/java/org/mosad/homeflix/application/SeriesDetailView.java +++ b/src/main/java/org/mosad/homeflix/application/view/SeriesDetailView.java @@ -20,7 +20,7 @@ * */ -package org.mosad.homeflix.application; +package org.mosad.homeflix.application.view; import java.awt.Desktop; import java.io.File; @@ -36,7 +36,6 @@ import org.mosad.homeflix.player.Player; import com.jfoenix.controls.JFXButton; -import javafx.animation.FadeTransition; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; @@ -46,14 +45,11 @@ import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane.ScrollBarPolicy; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; import javafx.scene.text.Text; -import javafx.util.Duration; -public class SeriesDetailView { +public class SeriesDetailView extends DetailView { - @FXML private AnchorPane seriesDVPane; @FXML private ScrollPane scrollPaneEpisodes; @FXML private HBox hBoxEpisodes; @@ -90,7 +86,7 @@ public class SeriesDetailView { public void initialize() { dbController = DBController.getInstance(); - seriesDVPane.setStyle("-fx-background-color: rgba(89,89,89,0.9);"); + rootPane.setStyle("-fx-background-color: rgba(89,89,89,0.9);"); scrollPaneEpisodes.setStyle("-fx-background-color: transparent;"); scrollPaneEpisodes.setHbarPolicy(ScrollBarPolicy.ALWAYS); @@ -188,6 +184,7 @@ public class SeriesDetailView { /** * update the text of all static GUI elements of FilmDeatilView */ + @Override public void updateGUILocal() { lblCrew.setText(XMLController.getLocalBundle().getString("crew")); lblDirectorsInfo.setText(XMLController.getLocalBundle().getString("directors")); @@ -195,31 +192,6 @@ public class SeriesDetailView { lblActorsInfo.setText(XMLController.getLocalBundle().getString("actors")); } - /** - * show the FilmDVpane - */ - public void showPane() { - seriesDVPane.setVisible(true); - FadeTransition fadeIn = new FadeTransition(Duration.millis(300), seriesDVPane); - fadeIn.setFromValue(0.3); - fadeIn.setToValue(1.0); - fadeIn.play(); - } - - /** - * hide the FilmDVpane - */ - private void hidePane() { - FadeTransition fadeOut = new FadeTransition(Duration.millis(200), seriesDVPane); - fadeOut.setFromValue(1.0); - fadeOut.setToValue(0.3); - fadeOut.play(); - - seriesDVPane.setVisible(false); - - MainWindowController.getInstance().disableBlur(); // disable blur - } - /** * add all episodes of one season to the ScrollPane * @param season the season to add diff --git a/src/main/resources/fxml/FilmDetailView.fxml b/src/main/resources/fxml/FilmDetailView.fxml index 4584853..3d7d4fb 100644 --- a/src/main/resources/fxml/FilmDetailView.fxml +++ b/src/main/resources/fxml/FilmDetailView.fxml @@ -12,7 +12,7 @@ - + diff --git a/src/main/resources/fxml/SeriesDetailView.fxml b/src/main/resources/fxml/SeriesDetailView.fxml index 0258a1a..88b2a2b 100644 --- a/src/main/resources/fxml/SeriesDetailView.fxml +++ b/src/main/resources/fxml/SeriesDetailView.fxml @@ -14,7 +14,7 @@ - +