Browse Source

fixed open folder btn when using Linux, more clean up

pull/12/head
Jannik 4 years ago
parent
commit
5600456556
  1. 1
      src/main/java/kellerkinder/HomeFlix/application/Main.java
  2. 97
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java
  3. 2
      src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java
  4. 4
      src/main/java/kellerkinder/HomeFlix/player/Player.java
  5. 12
      src/main/java/kellerkinder/HomeFlix/player/PlayerController.java

1
src/main/java/kellerkinder/HomeFlix/application/Main.java

@ -101,7 +101,6 @@ public class Main extends Application {
XMLController.getPosterCache().mkdir();
}
} catch (IOException e) {
LOGGER.error(e);
}

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

@ -32,12 +32,13 @@ import java.io.InputStreamReader;
import java.io.Writer;
import java.math.BigInteger;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.SwingUtilities;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kellerkinder.Alerts.JFXInfoAlert;
@ -93,9 +94,9 @@ import kellerkinder.HomeFlix.controller.DBController;
import kellerkinder.HomeFlix.controller.OMDbAPIController;
import kellerkinder.HomeFlix.controller.UpdateController;
import kellerkinder.HomeFlix.controller.XMLController;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
import kellerkinder.HomeFlix.datatypes.SourceDataType;
import kellerkinder.HomeFlix.player.Player;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
public class MainWindowController {
@ -163,14 +164,13 @@ public class MainWindowController {
// poster-mode
// @FXML private AnchorPane posterModeAnchorPane;
private static DBController dbController; // the player needs the initialized dbController
private DBController dbController;
private UpdateController updateController;
private XMLController xmlController;
private Stage primaryStage;
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
private boolean menuTrue = false;
private boolean settingsTrue = false;
private final String version = "0.7.0";
private final String buildNumber = "169";
@ -290,9 +290,8 @@ public class MainWindowController {
burgerTask.play();
menuTrue = true;
}
if (settingsTrue) {
if (settingsScrollPane.isVisible()) {
settingsScrollPane.setVisible(false);
settingsTrue = false;
}
});
@ -512,10 +511,11 @@ public class MainWindowController {
@FXML
private void openfolderbtnclicked() {
String dest = new File(getCurrentStreamUrl()).getParentFile().getAbsolutePath();
File dest = new File(getCurrentStreamUrl()).getParentFile();
if (!System.getProperty("os.name").contains("Linux")) {
try {
Desktop.getDesktop().open(new File(dest));
Desktop.getDesktop().open(dest);
} catch (IOException e) {
e.printStackTrace();
}
@ -543,12 +543,10 @@ public class MainWindowController {
@FXML
private void settingsBtnclicked() {
if (settingsTrue) {
if (settingsScrollPane.isVisible()) {
settingsScrollPane.setVisible(false);
settingsTrue = false;
} else {
settingsScrollPane.setVisible(true);
settingsTrue = true;
}
}
@ -613,8 +611,8 @@ public class MainWindowController {
* clear the FilmsList and FilmRoot children, then update the database
*/
private void refreshAllFilms() {
getFilmsList().clear();
getFilmRoot().getChildren().clear();
filmsList.clear();
filmRoot.getChildren().clear();
dbController.refreshDataBase(); // refreshes the database after a source path was added
filmsList = dbController.getDatabaseFilmsList(); // returns a list of all films stored in the database
addFilmsToTable(filmsList);
@ -690,7 +688,7 @@ public class MainWindowController {
// clear old sources list/table
getSourcesList().clear();
getSourceRoot().getChildren().clear();
sourceRoot.getChildren().clear();
// clear the FilmsList and FilmRoot children, then update the database
refreshAllFilms();
@ -809,27 +807,27 @@ public class MainWindowController {
ObservableList<Node> textFlow = getTextFlow().getChildren();
// TODO this should move! ***
ArrayList<Text> nameText = new ArrayList<Text>();
nameText.add(new Text(XMLController.getLocalBundle().getString("title") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("year") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("rated") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("released") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("season") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("episode") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("runtime") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("genre") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("director") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("writer") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("actors") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("plot") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("language") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("country") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("awards") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("metascore") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("imdbRating") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("type") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("boxOffice") + ": "));
nameText.add(new Text(XMLController.getLocalBundle().getString("website") + ": "));
Text[] nameText = new Text[20];
nameText[0] = new Text(XMLController.getLocalBundle().getString("title") + ": ");
nameText[1] = new Text(XMLController.getLocalBundle().getString("year") + ": ");
nameText[2] = new Text(XMLController.getLocalBundle().getString("rated") + ": ");
nameText[3] = new Text(XMLController.getLocalBundle().getString("released") + ": ");
nameText[4] = new Text(XMLController.getLocalBundle().getString("season") + ": ");
nameText[5] = new Text(XMLController.getLocalBundle().getString("episode") + ": ");
nameText[6] = new Text(XMLController.getLocalBundle().getString("runtime") + ": ");
nameText[7] = new Text(XMLController.getLocalBundle().getString("genre") + ": ");
nameText[8] = new Text(XMLController.getLocalBundle().getString("director") + ": ");
nameText[9] = new Text(XMLController.getLocalBundle().getString("writer") + ": ");
nameText[10] = new Text(XMLController.getLocalBundle().getString("actors") + ": ");
nameText[11] = new Text(XMLController.getLocalBundle().getString("plot") + ": ");
nameText[12] = new Text(XMLController.getLocalBundle().getString("language") + ": ");
nameText[13] = new Text(XMLController.getLocalBundle().getString("country") + ": ");
nameText[14] = new Text(XMLController.getLocalBundle().getString("awards") + ": ");
nameText[15] = new Text(XMLController.getLocalBundle().getString("metascore") + ": ");
nameText[16] = new Text(XMLController.getLocalBundle().getString("imdbRating") + ": ");
nameText[17] = new Text(XMLController.getLocalBundle().getString("type") + ": ");
nameText[18] = new Text(XMLController.getLocalBundle().getString("boxOffice") + ": ");
nameText[19] = new Text(XMLController.getLocalBundle().getString("website") + ": ");
// ***
// set the correct font for the nameText
@ -845,7 +843,7 @@ public class MainWindowController {
if (cacheData[i] != null && (i == 5 || i == 6) && cacheData[5].length() == 0) {
// do nothing
} else if(cacheData[i] != null){
textFlow.addAll(nameText.get(i), new Text(cacheData[i] + "\n"));
textFlow.addAll(nameText[i], new Text(cacheData[i] + "\n"));
}
}
@ -853,9 +851,9 @@ public class MainWindowController {
// add the image
try {
getPosterImageView().setImage(new Image(new File(cacheData[20]).toURI().toString()));
posterImageView.setImage(new Image(new File(cacheData[20]).toURI().toString()));
} catch (Exception e) {
getPosterImageView().setImage(new Image("icons/close_black_2048x2048.png"));
posterImageView.setImage(new Image("icons/close_black_2048x2048.png"));
LOGGER.error("No Poster found, useing default.");
}
}
@ -914,9 +912,6 @@ public class MainWindowController {
}
// getter and setter
public static DBController getDbController() {
return dbController;
}
public FilmTabelDataType getCurrentTableFilm() {
return currentTableFilm;
@ -938,35 +933,15 @@ public class MainWindowController {
return indexList;
}
public ObservableList<FilmTabelDataType> getFilmsList() {
return filmsList;
}
public static ObservableList<SourceDataType> getSourcesList() {
return sourcesList;
}
public TreeTableView<FilmTabelDataType> getFilmsTreeTable() {
return filmsTreeTable;
}
public TextFlow getTextFlow() {
return textFlow;
}
public ImageView getPosterImageView() {
return posterImageView;
}
public JFXButton getUpdateBtn() {
return updateBtn;
}
public TreeItem<FilmTabelDataType> getFilmRoot() {
return filmRoot;
}
public TreeItem<SourceDataType> getSourceRoot() {
return sourceRoot;
}
}

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

@ -61,7 +61,7 @@ public class SourcesController {
for (JsonValue source : sources) {
String path = source.asObject().getString("path", "");
String mode = source.asObject().getString("mode", "");
MainWindowController.getSourcesList().add(new SourceDataType(path, mode));
MainWindowController.getSourcesList().add(new SourceDataType(path, mode)); // TODO
if (mode.equals("local"))
addLocalSource(path);

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

@ -30,7 +30,7 @@ import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import kellerkinder.HomeFlix.application.Main;
import kellerkinder.HomeFlix.application.MainWindowController;
import kellerkinder.HomeFlix.controller.DBController;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
public class Player {
@ -59,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(currentTableFilm.getStreamUrl(),
DBController.getInstance().setCurrentTime(currentTableFilm.getStreamUrl(),
playerController.getCurrentTime());
playerController.getMediaPlayer().stop();
stage.close();

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

@ -47,7 +47,7 @@ import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaPlayer.Status;
import javafx.scene.media.MediaView;
import javafx.util.Duration;
import kellerkinder.HomeFlix.application.MainWindowController;
import kellerkinder.HomeFlix.controller.DBController;
import kellerkinder.HomeFlix.controller.XMLController;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
@ -122,7 +122,7 @@ public class PlayerController {
width.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width"));
height.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height"));
startTime = MainWindowController.getDbController().getCurrentTime(film.getStreamUrl());
startTime = DBController.getInstance().getCurrentTime(film.getStreamUrl());
autoplay = XMLController.isAutoplay();
season = !film.getSeason().isEmpty() ? Integer.parseInt(film.getSeason()) : 0;
episode = !film.getEpisode().isEmpty() ? Integer.parseInt(film.getEpisode()) : 0;
@ -175,7 +175,7 @@ public class PlayerController {
} else if (timeToEnd < 120) {
// if we are 120ms to the end stop the media
mediaPlayer.stop();
MainWindowController.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
DBController.getInstance().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
playBtn.setGraphic(play_arrow_black);
} else {
if (nextEpBtn.isVisible())
@ -253,7 +253,7 @@ public class PlayerController {
@FXML
void stopBtnAction(ActionEvent event) {
MainWindowController.getDbController().setCurrentTime(film.getStreamUrl(), currentTime);
DBController.getInstance().setCurrentTime(film.getStreamUrl(), currentTime);
mediaPlayer.stop();
player.getStage().close();
}
@ -287,8 +287,8 @@ public class PlayerController {
private void autoPlayNewFilm() {
autoplay = false;
MainWindowController.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
FilmTabelDataType nextFilm = MainWindowController.getDbController().getNextEpisode(film.getTitle(), episode, season);
DBController.getInstance().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
FilmTabelDataType nextFilm = DBController.getInstance().getNextEpisode(film.getTitle(), episode, season);
if (nextFilm != null) {
mediaPlayer.stop();
film = nextFilm;

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