|
|
@ -1,43 +1,198 @@ |
|
|
|
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.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; |
|
|
|
import kellerkinder.HomeFlix.controller.DBController; |
|
|
|
import kellerkinder.HomeFlix.controller.XMLController; |
|
|
|
|
|
|
|
public class FilmDetailView { |
|
|
|
|
|
|
|
@FXML private AnchorPane filmDVPane; |
|
|
|
|
|
|
|
@FXML private Label lblTitle; |
|
|
|
@FXML private Label lblYear; |
|
|
|
@FXML private Label lblScore; |
|
|
|
|
|
|
|
@FXML private JFXButton btnWhishlist; |
|
|
|
@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 Label lblInfo; |
|
|
|
@FXML private Label lblRuntimeInfo; |
|
|
|
@FXML private Label lblRuntime; |
|
|
|
@FXML private Label lblLanguageInfo; |
|
|
|
@FXML private Label lblLanguage; |
|
|
|
@FXML private Label lblRevenueInfo; |
|
|
|
@FXML private Label lblRevenue; |
|
|
|
@FXML private Label lblRatingInfo; |
|
|
|
@FXML private Label lblRating; |
|
|
|
|
|
|
|
@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; |
|
|
|
|
|
|
|
private DBController dbController; |
|
|
|
private static final Logger LOGGER = LogManager.getLogger(FilmDetailView.class.getName()); |
|
|
|
private String currentStreamURL; |
|
|
|
|
|
|
|
public void initialize() { |
|
|
|
System.out.println("init nested controller"); |
|
|
|
dbController = DBController.getInstance(); |
|
|
|
filmDVPane.setStyle("-fx-background-color: rgba(89,89,89,0.9);"); |
|
|
|
btnWhishlist.setGraphic(new ImageView(new Image("icons/ic_play_arrow_black_18dp_1x.png"))); |
|
|
|
} |
|
|
|
|
|
|
|
public void foo() { |
|
|
|
System.out.println("test"); |
|
|
|
@FXML |
|
|
|
private void btnWishlistAction() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@FXML |
|
|
|
private void btnWhishlistAction() { |
|
|
|
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 btnFavouriteAction() { |
|
|
|
private void btnHideAction() { |
|
|
|
hidePane(); |
|
|
|
} |
|
|
|
|
|
|
|
@FXML |
|
|
|
private void btnPlayAction() { |
|
|
|
playFilm(); |
|
|
|
} |
|
|
|
|
|
|
|
@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 stream to the FilmDetailView |
|
|
|
* @param streamURL URL of the stream |
|
|
|
*/ |
|
|
|
public void setFilm(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]); |
|
|
|
|
|
|
|
lblRuntime.setText(cacheInfo[6]); |
|
|
|
lblLanguage.setText(cacheInfo[12]); |
|
|
|
lblRevenue.setText(cacheInfo[18]); |
|
|
|
lblRating.setText(cacheInfo[2]); |
|
|
|
|
|
|
|
try { |
|
|
|
if (new File(cacheInfo[20]).isFile()) { |
|
|
|
imgPoster.setImage(new Image(new File(cacheInfo[20]).toURI().toString())); |
|
|
|
} else { |
|
|
|
imgPoster.setImage(new Image(cacheInfo[20])); |
|
|
|
} |
|
|
|
} 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")); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 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")); |
|
|
|
|
|
|
|
lblInfo.setText(XMLController.getLocalBundle().getString("info")); |
|
|
|
lblRuntimeInfo.setText(XMLController.getLocalBundle().getString("runtime")); |
|
|
|
lblLanguageInfo.setText(XMLController.getLocalBundle().getString("language")); |
|
|
|
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() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|