2019-06-21 21:16:53 +02:00
/ * *
* Project - HomeFlix
*
2022-02-06 18:46:19 +01:00
* Copyright 2016 - 2022 < @Seil0 >
2019-06-21 21:16:53 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston ,
* MA 02110 - 1301 , USA .
*
* /
2020-05-22 17:12:07 +02:00
package org.mosad.homeflix.application.view ;
2019-06-16 13:00:29 +02:00
2019-06-16 21:44:42 +02:00
import java.awt.Desktop ;
import java.io.File ;
import java.io.IOException ;
import org.apache.logging.log4j.LogManager ;
import org.apache.logging.log4j.Logger ;
2020-04-22 18:29:39 +02:00
import org.mosad.homeflix.controller.DBController ;
import org.mosad.homeflix.controller.XMLController ;
import org.mosad.homeflix.datatypes.OMDbAPIResponseDataType ;
import org.mosad.homeflix.player.Player ;
2019-06-16 21:44:42 +02:00
2019-06-16 15:23:17 +02:00
import com.jfoenix.controls.JFXButton ;
2019-06-16 13:00:29 +02:00
import javafx.fxml.FXML ;
import javafx.scene.control.Label ;
2019-06-16 15:23:17 +02:00
import javafx.scene.image.Image ;
import javafx.scene.image.ImageView ;
import javafx.scene.text.Text ;
2019-06-16 13:00:29 +02:00
2020-05-22 17:12:07 +02:00
public class FilmDetailView extends DetailView {
2019-06-16 21:44:42 +02:00
2019-06-16 15:23:17 +02:00
@FXML private Label lblTitle ;
@FXML private Label lblYear ;
@FXML private Label lblScore ;
2019-06-16 21:44:42 +02:00
@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 ;
2019-06-16 15:23:17 +02:00
@FXML private JFXButton btnFavourite ;
2019-06-16 21:44:42 +02:00
@FXML private JFXButton btnHide ;
@FXML private JFXButton btnPlay ;
@FXML private JFXButton btnDirectory ;
2019-06-17 00:44:44 +02:00
@FXML private ImageView wishlistIcon ;
2019-06-16 21:44:42 +02:00
@FXML private ImageView favoriteIcon ;
@FXML private ImageView imgPoster ;
2019-06-16 15:23:17 +02:00
@FXML private Text textPlot ;
2019-06-16 13:00:29 +02:00
2019-06-16 21:44:42 +02:00
private DBController dbController ;
private static final Logger LOGGER = LogManager . getLogger ( FilmDetailView . class . getName ( ) ) ;
private String currentStreamURL ;
2019-06-16 13:00:29 +02:00
public void initialize ( ) {
2019-06-16 21:44:42 +02:00
dbController = DBController . getInstance ( ) ;
2020-05-22 17:12:07 +02:00
rootPane . setStyle ( " -fx-background-color: rgba(89,89,89,0.9); " ) ;
2019-06-16 13:00:29 +02:00
}
2019-06-16 21:44:42 +02:00
@FXML
private void btnWishlistAction ( ) {
2019-06-16 13:00:29 +02:00
}
2019-06-16 15:23:17 +02:00
@FXML
2019-06-16 21:44:42 +02:00
private void btnFavouriteAction ( ) {
dbController . toggleFavoriteState ( currentStreamURL ) ;
2019-06-16 15:23:17 +02:00
2019-06-16 21:44:42 +02:00
// 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 " ) ) ;
}
2019-06-16 15:23:17 +02:00
}
@FXML
2019-06-16 21:44:42 +02:00
private void btnHideAction ( ) {
hidePane ( ) ;
}
@FXML
private void btnPlayAction ( ) {
2020-05-22 17:12:07 +02:00
new Player ( currentStreamURL ) ;
2019-06-16 21:44:42 +02:00
}
@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 ;
2020-04-22 18:29:39 +02:00
OMDbAPIResponseDataType cacheInfo = dbController . readCache ( streamURL ) ; // get the cache data from the database
2019-06-16 21:44:42 +02:00
// add the cache data to the GUI
2020-04-22 18:29:39 +02:00
lblTitle . setText ( cacheInfo . getTitle ( ) ) ;
lblYear . setText ( " ( " + cacheInfo . getYear ( ) + " ) " ) ;
lblScore . setText ( XMLController . getLocalBundle ( ) . getString ( " score " ) + " : " + cacheInfo . getMetascore ( ) + " % " ) ;
2019-06-16 21:44:42 +02:00
2020-04-22 18:29:39 +02:00
textPlot . setText ( cacheInfo . getPlot ( ) ) ;
2019-06-16 21:44:42 +02:00
2020-04-22 18:29:39 +02:00
lblDirectors . setText ( cacheInfo . getDirector ( ) ) ;
lblWriters . setText ( cacheInfo . getWriter ( ) ) ;
lblActors . setText ( cacheInfo . getActors ( ) ) ;
2019-06-16 21:44:42 +02:00
2020-04-22 18:29:39 +02:00
lblRuntime . setText ( cacheInfo . getRuntime ( ) ) ;
lblLanguage . setText ( cacheInfo . getLanguage ( ) ) ;
lblRevenue . setText ( cacheInfo . getBoxOffice ( ) ) ;
lblRating . setText ( cacheInfo . getRated ( ) ) ;
2019-06-16 21:44:42 +02:00
try {
2020-04-22 18:29:39 +02:00
if ( new File ( cacheInfo . getPoster ( ) ) . isFile ( ) ) {
imgPoster . setImage ( new Image ( new File ( cacheInfo . getPoster ( ) ) . toURI ( ) . toString ( ) ) ) ;
2019-06-16 21:44:42 +02:00
} else {
2020-04-22 18:29:39 +02:00
imgPoster . setImage ( new Image ( cacheInfo . getPoster ( ) ) ) ;
2019-06-16 21:44:42 +02:00
}
} 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
* /
2020-05-22 17:12:07 +02:00
@Override
2019-06-16 21:44:42 +02:00
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 " ) ) ;
}
2019-06-16 13:00:29 +02:00
}