9 changed files with 326 additions and 70 deletions
@ -1,10 +1,216 @@
|
||||
package kellerkinder.HomeFlix.application; |
||||
|
||||
import java.awt.Desktop; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
|
||||
import org.apache.logging.log4j.LogManager; |
||||
import org.apache.logging.log4j.Logger; |
||||
|
||||
import com.jfoenix.controls.JFXButton; |
||||
|
||||
import javafx.animation.FadeTransition; |
||||
import javafx.collections.FXCollections; |
||||
import javafx.collections.ObservableList; |
||||
import javafx.fxml.FXML; |
||||
import javafx.scene.control.ChoiceBox; |
||||
import javafx.scene.control.Label; |
||||
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; |
||||
import kellerkinder.HomeFlix.controller.DBController; |
||||
import kellerkinder.HomeFlix.controller.XMLController; |
||||
import kellerkinder.HomeFlix.datatypes.SeriresDVEpisode; |
||||
|
||||
public class SeriesDetailView { |
||||
|
||||
@FXML private AnchorPane seriesDVPane; |
||||
@FXML private ScrollPane scrollPaneEpisodes; |
||||
|
||||
@FXML private HBox hBoxEpisodes; |
||||
|
||||
@FXML private Label lblTitle; |
||||
@FXML private Label lblYear; |
||||
@FXML private Label lblScore; |
||||
|
||||
@FXML private Label lblCrew; |
||||
@FXML private Label lblDirectors; |
||||
@FXML private Label lblDirectorsInfo; |
||||
@FXML private Label lblWriters; |
||||
@FXML private Label lblWritersInfo; |
||||
@FXML private Label lblActors; |
||||
@FXML private Label lblActorsInfo; |
||||
|
||||
@FXML private JFXButton btnWishlist; |
||||
@FXML private JFXButton btnFavourite; |
||||
@FXML private JFXButton btnHide; |
||||
@FXML private JFXButton btnPlay; |
||||
@FXML private JFXButton btnDirectory; |
||||
|
||||
@FXML private ImageView wishlistIcon; |
||||
@FXML private ImageView favoriteIcon; |
||||
@FXML private ImageView imgPoster; |
||||
|
||||
@FXML private Text textPlot; |
||||
|
||||
@FXML private ChoiceBox<String> cbSeason; |
||||
|
||||
private DBController dbController; |
||||
private static final Logger LOGGER = LogManager.getLogger(SeriesDetailView.class.getName()); |
||||
private String currentStreamURL; |
||||
|
||||
public void initialize() { |
||||
dbController = DBController.getInstance(); |
||||
seriesDVPane.setStyle("-fx-background-color: rgba(89,89,89,0.9);"); |
||||
scrollPaneEpisodes.setStyle("-fx-background-color: transparent;"); |
||||
scrollPaneEpisodes.setHbarPolicy(ScrollBarPolicy.ALWAYS); |
||||
|
||||
cbSeason.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> { |
||||
addEpisodes(newValue.intValue() + 1); |
||||
}); |
||||
} |
||||
|
||||
@FXML |
||||
private void btnWishlistAction() { |
||||
|
||||
} |
||||
|
||||
@FXML |
||||
private void btnFavouriteAction() { |
||||
dbController.toggleFavoriteState(currentStreamURL); |
||||
|
||||
// update the favorite icon
|
||||
if(dbController.getFavoriteState(currentStreamURL) == 1) { |
||||
favoriteIcon.setImage(new Image("icons/baseline_favorite_black_48dp.png")); |
||||
} else { |
||||
favoriteIcon.setImage(new Image("icons/baseline_favorite_border_black_48dp.png")); |
||||
} |
||||
} |
||||
|
||||
@FXML |
||||
private void btnHideAction() { |
||||
hidePane(); |
||||
} |
||||
|
||||
@FXML |
||||
private void btnPlayAction() { |
||||
// playFilm(); // TODO
|
||||
} |
||||
|
||||
@FXML |
||||
private void btnDirectoryAction() { |
||||
File dest = new File(currentStreamURL).getParentFile(); |
||||
|
||||
if (!System.getProperty("os.name").contains("Linux")) { |
||||
try { |
||||
Desktop.getDesktop().open(dest); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* set the cached data of a series to the SeriesDetailView |
||||
* @param streamURL URL of the series root directory |
||||
*/ |
||||
public void setSeries(String streamURL) { |
||||
currentStreamURL = streamURL; |
||||
String[] cacheInfo = dbController.readCache(streamURL); // get the cache data from the database
|
||||
|
||||
// add the cache data to the GUI
|
||||
lblTitle.setText(cacheInfo[0]); |
||||
lblYear.setText("(" + cacheInfo[1] + ")"); |
||||
lblScore.setText(XMLController.getLocalBundle().getString("score") + ": " + cacheInfo[15] + "%"); |
||||
|
||||
textPlot.setText(cacheInfo[11]); |
||||
|
||||
lblDirectors.setText(cacheInfo[8]); |
||||
lblWriters.setText(cacheInfo[9]); |
||||
lblActors.setText(cacheInfo[10]); |
||||
|
||||
try { |
||||
imgPoster.setImage(new Image(new File(cacheInfo[20]).toURI().toString())); |
||||
} catch (Exception e) { |
||||
imgPoster.setImage(new Image("icons/Homeflix_Poster.png")); |
||||
LOGGER.error("No Poster found, useing default."); |
||||
} |
||||
|
||||
// set the favorite correct icon
|
||||
if(dbController.getFavoriteState(streamURL) == 1) { |
||||
favoriteIcon.setImage(new Image("icons/baseline_favorite_black_48dp.png")); |
||||
} else { |
||||
favoriteIcon.setImage(new Image("icons/baseline_favorite_border_black_48dp.png")); |
||||
} |
||||
|
||||
// add all seasons to the ChoiceBox
|
||||
ObservableList<String> seasons = FXCollections.observableArrayList(); |
||||
for (int i = 1; i <= new File(currentStreamURL).listFiles().length; i++) { |
||||
seasons.add("Season " + i); |
||||
} |
||||
cbSeason.getItems().clear(); |
||||
cbSeason.setItems(seasons); |
||||
cbSeason.getSelectionModel().select(0); |
||||
|
||||
// add all episodes for season 1
|
||||
addEpisodes(1); |
||||
} |
||||
|
||||
/** |
||||
* update the text of all static GUI elements of FilmDeatilView |
||||
*/ |
||||
public void updateGUILocal() { |
||||
lblCrew.setText(XMLController.getLocalBundle().getString("crew")); |
||||
lblDirectorsInfo.setText(XMLController.getLocalBundle().getString("directors")); |
||||
lblWritersInfo.setText(XMLController.getLocalBundle().getString("writers")); |
||||
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 |
||||
*/ |
||||
private void addEpisodes(int season) { |
||||
hBoxEpisodes.getChildren().clear(); |
||||
for (String[] episodePoster : dbController.getEpisodes(new File(currentStreamURL).getName(), season)) { |
||||
Image poster; |
||||
try { |
||||
poster = new Image(episodePoster[2].length() > 0 ? new File(episodePoster[2]).toURI().toString() : "icons/Homeflix_Poster.png"); |
||||
} catch (Exception e) { |
||||
poster = new Image("icons/Homeflix_Poster.png"); |
||||
} |
||||
hBoxEpisodes.getChildren().add(new SeriresDVEpisode(episodePoster[0], episodePoster[1], poster)); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,67 @@
|
||||
package kellerkinder.HomeFlix.datatypes; |
||||
|
||||
import javafx.scene.control.Label; |
||||
import javafx.scene.image.Image; |
||||
import javafx.scene.image.ImageView; |
||||
import javafx.scene.input.MouseEvent; |
||||
import javafx.scene.layout.AnchorPane; |
||||
import kellerkinder.HomeFlix.player.Player; |
||||
|
||||
public class SeriresDVEpisode extends AnchorPane { |
||||
|
||||
private String streamURL; |
||||
private Label label = new Label(); |
||||
private ImageView imageView = new ImageView(); |
||||
|
||||
public SeriresDVEpisode() { |
||||
super.getChildren().addAll(imageView, label); |
||||
super.prefWidth(200); |
||||
super.prefHeight(112); |
||||
|
||||
|
||||
imageView.setPreserveRatio(true); |
||||
imageView.setFitHeight(112); |
||||
|
||||
label.setStyle("-fx-text-fill: #ffffff; -fx-font-size: 14pt ; -fx-font-weight: bold;"); |
||||
super.setTopAnchor(label, 3.0); |
||||
super.setLeftAnchor(label, 7.0); |
||||
} |
||||
|
||||
public SeriresDVEpisode(String streamURL, String episode, Image poster) { |
||||
this(); |
||||
|
||||
this.streamURL = streamURL; |
||||
|
||||
label.setText(episode); |
||||
imageView.setImage(poster); |
||||
imageView.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> { |
||||
// Always play with the integrated Player TODO
|
||||
new Player(streamURL); |
||||
}); |
||||
} |
||||
|
||||
public String getStreamURL() { |
||||
return streamURL; |
||||
} |
||||
|
||||
public Label getLabel() { |
||||
return label; |
||||
} |
||||
|
||||
public ImageView getImageView() { |
||||
return imageView; |
||||
} |
||||
|
||||
public void setStreamURL(String streamURL) { |
||||
this.streamURL = streamURL; |
||||
} |
||||
|
||||
public void setLabel(Label label) { |
||||
this.label = label; |
||||
} |
||||
|
||||
public void setImageView(ImageView imageView) { |
||||
this.imageView = imageView; |
||||
} |
||||
|
||||
} |
Before Width: | Height: | Size: 6.5 KiB |
Loading…
Reference in new issue