code cleanup
This commit is contained in:
		| @ -17,12 +17,13 @@ | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
| 	</classpathentry> | ||||
| 	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||||
| 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9"> | ||||
| 		<attributes> | ||||
| 			<attribute name="module" value="true"/> | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
| 	</classpathentry> | ||||
| 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9"> | ||||
| 	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||||
| 		<attributes> | ||||
| 			<attribute name="maven.pomderived" value="true"/> | ||||
| 		</attributes> | ||||
|  | ||||
| @ -1,5 +1,13 @@ | ||||
| eclipse.preferences.version=1 | ||||
| org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||||
| org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | ||||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 | ||||
| org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||||
| org.eclipse.jdt.core.compiler.compliance=9 | ||||
| org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||||
| org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||||
| org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||||
| org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||||
| org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||||
| org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||||
| org.eclipse.jdt.core.compiler.source=9 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| /** | ||||
|  * Project-HomeFlix | ||||
|  *  | ||||
|  * | ||||
|  * Copyright 2016-2018  <@Seil0> | ||||
|  *  | ||||
|  * This program is free software; you can redistribute it and/or modify | ||||
| @ -37,7 +37,6 @@ import java.io.StringWriter; | ||||
| import java.io.Writer; | ||||
| import java.math.BigInteger; | ||||
| import java.net.URLConnection; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Locale; | ||||
| import java.util.Properties; | ||||
| import java.util.ResourceBundle; | ||||
| @ -237,8 +236,6 @@ public class MainWindowController { | ||||
| 	private String versionName = "glowing vampire"; | ||||
| 	private String dialogBtnStyle; | ||||
| 	private String color; | ||||
| 	private String title; | ||||
| 	private String streamUrl; | ||||
| 	private String ratingSortType; | ||||
| 	private String local; | ||||
| 	private String omdbAPIKey; | ||||
| @ -256,7 +253,7 @@ public class MainWindowController { | ||||
| 	private int indexList; | ||||
| 	private int next; | ||||
| 	private ResourceBundle bundle; | ||||
| 	private FilmTabelDataType currentFilm; | ||||
| 	private FilmTabelDataType currentTableFilm = new FilmTabelDataType("", "", "", "", false, false, null); | ||||
| 	 | ||||
| 	private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); | ||||
| 	private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta"); | ||||
| @ -296,8 +293,8 @@ public class MainWindowController { | ||||
| 		loadSettings(); | ||||
| 		checkAutoUpdate(); | ||||
| 		initTabel(); | ||||
| 		initActions(); | ||||
| 		initUI(); | ||||
| 		initActions(); | ||||
| 	} | ||||
| 	 | ||||
| 	// Initialize the tables (treeTableViewfilm and sourcesTable) | ||||
| @ -415,8 +412,8 @@ public class MainWindowController { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { | ||||
| 				setSize(fontsizeSlider.getValue()); | ||||
| 				if (title != null) { | ||||
| 					dbController.readCache(streamUrl); | ||||
| 				if (!getCurrentTitle().isEmpty()) { | ||||
| 					dbController.readCache(getCurrentStreamUrl()); | ||||
| 				} | ||||
| 				// ta1.setFont(Font.font("System", size)); | ||||
| 				saveSettings(); | ||||
| @ -426,8 +423,8 @@ public class MainWindowController { | ||||
| 		like.setOnAction(new EventHandler<ActionEvent>() { | ||||
| 			@Override | ||||
| 			public void handle(ActionEvent event) { | ||||
| 				dbController.like(streamUrl); | ||||
| 				dbController.refresh(streamUrl, indexList); | ||||
| 				dbController.like(getCurrentStreamUrl()); | ||||
| 				dbController.refresh(getCurrentStreamUrl(), indexList); | ||||
| 				refreshTable(); | ||||
| 			} | ||||
| 		}); | ||||
| @ -435,8 +432,8 @@ public class MainWindowController { | ||||
| 		dislike.setOnAction(new EventHandler<ActionEvent>() { | ||||
| 			@Override | ||||
| 			public void handle(ActionEvent event) { | ||||
| 				dbController.dislike(streamUrl); | ||||
| 				dbController.refresh(streamUrl, indexList); | ||||
| 				dbController.dislike(getCurrentStreamUrl()); | ||||
| 				dbController.refresh(getCurrentStreamUrl(), indexList); | ||||
| 				refreshTable(); | ||||
| 			} | ||||
| 		}); | ||||
| @ -448,45 +445,25 @@ public class MainWindowController { | ||||
| 		columnFavorite.sortTypeProperty().addListener(new ChangeListener<SortType>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) { | ||||
| 				LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2); | ||||
| 				ArrayList<Integer> fav_true = new ArrayList<Integer>(); | ||||
| 				ArrayList<Integer> fav_false = new ArrayList<Integer>(); | ||||
| 				ObservableList<FilmTabelDataType> helpData; | ||||
| 				filterData.removeAll(filterData); | ||||
| //				treeTableViewfilm.getSelectionModel().clearSelection(selected); | ||||
| 				filmRoot.getChildren().removeAll(filmRoot.getChildren()); | ||||
|  | ||||
| 				helpData = filmsList; | ||||
|  | ||||
| 				for (int i = 0; i < helpData.size(); i++) { | ||||
| 					if (helpData.get(i).getFavorite() == true) { | ||||
| 						fav_true.add(i); | ||||
| 					} else { | ||||
| 						fav_false.add(i); | ||||
| 					} | ||||
| 				} | ||||
| 				if (paramT2.toString().equals("DESCENDING")) { | ||||
| 					LOGGER.info("Absteigend"); // Debug, delete? | ||||
| 					for (int i = 0; i < fav_true.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_true.get(i))); | ||||
| 					} | ||||
| 					for (int i = 0; i < fav_false.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_false.get(i))); | ||||
| 				filmRoot.getChildren().clear(); | ||||
| 				 | ||||
| 				if (paramT2.equals(SortType.DESCENDING)) { | ||||
| 					for (FilmTabelDataType film : filmsList) { | ||||
| 						if (film.getFavorite()) { | ||||
| 							filmRoot.getChildren().add(0, new TreeItem<FilmTabelDataType>(film)); | ||||
| 						} else { | ||||
| 							filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(film)); | ||||
| 						} | ||||
| 					} | ||||
| 				} else { | ||||
| 					for (int i = 0; i < fav_false.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_false.get(i))); | ||||
| 					System.out.println("ascending"); | ||||
| 					for (FilmTabelDataType film : filmsList) { | ||||
| 						if (!film.getFavorite()) { | ||||
| 							filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(film)); | ||||
| 						} else { | ||||
| 							filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(film)); | ||||
| 						} | ||||
| 					} | ||||
| 					for (int i = 0; i < fav_true.size(); i++) { | ||||
| 						filterData.add(helpData.get(fav_true.get(i))); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				LOGGER.info(filterData.size()); // Debug, delete? | ||||
| 				for (int i = 0; i < filterData.size(); i++) { | ||||
| //					LOGGER.info(filterData.get(i).getTitle()+"; "+filterData.get(i).getRating()); // Debugging | ||||
| 					// add filtered data to root node after search | ||||
| 					filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(filterData.get(i))); 				 | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
| @ -495,23 +472,16 @@ public class MainWindowController { | ||||
| 		filmsTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() { | ||||
| 			@Override | ||||
| 			public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) { | ||||
| 				indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected item | ||||
| 				currentTableFilm = filmsTreeTable.getSelectionModel().getSelectedItem().getValue(); // set the current film object | ||||
| 				indexList = filmsList.indexOf(currentTableFilm); // get selected items list index | ||||
| 				indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected items table index | ||||
| 				 | ||||
| 				last = indexTable - 1; | ||||
| 				next = indexTable + 1; | ||||
| 				title = columnTitle.getCellData(indexTable); // get name of selected item | ||||
| 				streamUrl = columnStreamUrl.getCellData(indexTable); // get file path of selected item | ||||
| 				 | ||||
| 				for (FilmTabelDataType helpData : filmsList) { | ||||
| 					if (helpData.getStreamUrl().equals(streamUrl)) { | ||||
| 						indexList = filmsList.indexOf(helpData); | ||||
| 					} | ||||
| 				} | ||||
| 				 | ||||
| 				currentFilm = filmsList.get(indexList); | ||||
| 				 | ||||
| 				if (filmsList.get(indexList).getCached()) { | ||||
| 					LOGGER.info("loading from cache: " + title); | ||||
| 					dbController.readCache(streamUrl); | ||||
| 				if (currentTableFilm.getCached()) { | ||||
| 					LOGGER.info("loading from cache: " + getCurrentTitle()); | ||||
| 					dbController.readCache(getCurrentStreamUrl()); | ||||
| 				} else { | ||||
| 					omdbAPIController = new OMDbAPIController(mainWindowController, dbController, main); | ||||
| 					Thread omdbAPIThread = new Thread(omdbAPIController); | ||||
| @ -548,8 +518,8 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void playbtnclicked() {	 | ||||
| 		if (isSupportedFormat(currentFilm)) { | ||||
| 			new Player(currentFilm, dbController); | ||||
| 		if (isSupportedFormat(currentTableFilm)) { | ||||
| 			new Player(currentTableFilm, dbController); | ||||
| 		} else { | ||||
| 			LOGGER.error("using fallback player!"); | ||||
| 			 | ||||
| @ -573,7 +543,7 @@ public class MainWindowController { | ||||
| 					vlcInfoAlert.showAndWait(); | ||||
| 				} else { | ||||
| 					try { | ||||
| 						new ProcessBuilder("vlc", streamUrl).start(); | ||||
| 						new ProcessBuilder("vlc", getCurrentStreamUrl()).start(); | ||||
| 					} catch (IOException e1) { | ||||
| 						showErrorMsg(errorPlay, e1); | ||||
| 					} | ||||
| @ -581,7 +551,7 @@ public class MainWindowController { | ||||
| 				 | ||||
| 			} else if (System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")) { | ||||
| 				try { | ||||
| 					Desktop.getDesktop().open(new File(streamUrl)); | ||||
| 					Desktop.getDesktop().open(new File(getCurrentStreamUrl())); | ||||
| 				} catch (IOException e1) { | ||||
| 					showErrorMsg(errorPlay, e1); | ||||
| 				} | ||||
| @ -603,7 +573,7 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void openfolderbtnclicked() { | ||||
| 		String dest = new File(streamUrl).getParentFile().getAbsolutePath(); | ||||
| 		String dest = new File(getCurrentStreamUrl()).getParentFile().getAbsolutePath(); | ||||
| 		if (!System.getProperty("os.name").contains("Linux")) { | ||||
| 			try { | ||||
| 				Desktop.getDesktop().open(new File(dest)); | ||||
| @ -699,6 +669,12 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	// refresh the selected child of the root node | ||||
| 	private void refreshTable() { | ||||
| 		System.out.println("refresh"); | ||||
| 		System.out.println(filmRoot.getChildren().get(indexTable).getValue()); | ||||
| 		System.out.println(currentTableFilm); | ||||
| 		 | ||||
| //		filmRoot.getChildren().get() | ||||
| 		 | ||||
| 		filmRoot.getChildren().get(indexTable).setValue(filmsList.get(indexList)); | ||||
| 	} | ||||
| 	 | ||||
| @ -1047,12 +1023,12 @@ public class MainWindowController { | ||||
| 		return color; | ||||
| 	} | ||||
|  | ||||
| 	public String getTitle() { | ||||
| 		return title; | ||||
| 	public String getCurrentTitle() { | ||||
| 		return currentTableFilm.getTitle(); | ||||
| 	} | ||||
|  | ||||
| 	public String getStreamUrl() { | ||||
| 		return streamUrl; | ||||
| 	public String getCurrentStreamUrl() { | ||||
| 		return currentTableFilm.getStreamUrl(); | ||||
| 	} | ||||
|  | ||||
| 	public void setSize(Double input) { | ||||
|  | ||||
| @ -64,7 +64,7 @@ public class OMDbAPIController implements Runnable { | ||||
| 		// get by title, TODO implement search FIXME set correct info if film dosen't exist | ||||
| 		try { | ||||
| 			URL apiUrl = new URL(URL + mainWindowController.getOmdbAPIKey() + "&t=" | ||||
| 					+ mainWindowController.getTitle().replace(" ", "%20")); | ||||
| 					+ mainWindowController.getCurrentTitle().replace(" ", "%20")); | ||||
| 			BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream())); | ||||
| 			output = ina.readLine(); | ||||
| 			ina.close(); | ||||
| @ -102,7 +102,7 @@ public class OMDbAPIController implements Runnable { | ||||
| 		//resize the image to fit in the posterImageView and add it to the cache | ||||
| 	    try { | ||||
| 			BufferedImage originalImage = ImageIO.read(new URL(responseString[18])); //change path to where file is located | ||||
| 		    posterPath = main.getPosterCache() + "/" + mainWindowController.getTitle() + ".png"; | ||||
| 		    posterPath = main.getPosterCache() + "/" + mainWindowController.getCurrentTitle() + ".png"; | ||||
| 			ImageIO.write(originalImage, "png", new File(posterPath)); | ||||
| 			LOGGER.info("adding poster to cache: "+posterPath); | ||||
| 		} catch (Exception e) { | ||||
| @ -110,16 +110,16 @@ public class OMDbAPIController implements Runnable { | ||||
| 		} | ||||
| 	     | ||||
| 		// adding strings to the cache | ||||
| 		dbController.addCache(mainWindowController.getStreamUrl(), responseString[0], responseString[1], | ||||
| 		dbController.addCache(mainWindowController.getCurrentStreamUrl(), responseString[0], responseString[1], | ||||
| 				responseString[2], responseString[3], responseString[4], responseString[5], responseString[6], | ||||
| 				responseString[7], responseString[8], responseString[9], responseString[10], responseString[11], | ||||
| 				responseString[12], responseString[13], responseString[14], responseString[15], responseString[16], | ||||
| 				responseString[17], posterPath, responseString[19]); | ||||
| 		dbController.setCached(mainWindowController.getStreamUrl()); | ||||
| 		dbController.setCached(mainWindowController.getCurrentStreamUrl()); | ||||
| 		 | ||||
| 		// load data to the MainWindowController | ||||
| 		Platform.runLater(() -> { | ||||
| 			dbController.readCache(mainWindowController.getStreamUrl()); | ||||
| 			dbController.readCache(mainWindowController.getCurrentStreamUrl()); | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -137,8 +137,7 @@ public class PlayerController { | ||||
| 		    @Override | ||||
| 		        public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) { | ||||
| 		    	currentTime = newValue.toMillis(); | ||||
| 		    	int episode = 0; | ||||
| 		    	if (film.getEpisode().length() != 0) episode = Integer.parseInt(film.getEpisode()); | ||||
| 		    	int episode = !film.getEpisode().isEmpty() ? Integer.parseInt(film.getEpisode()) : 0; | ||||
| 		    	 | ||||
| 		    	if ((duration - currentTime) < 10000 && episode != 0 && autoplay) { | ||||
| 		    		autoplay = false; | ||||
| @ -147,7 +146,6 @@ public class PlayerController { | ||||
| 		    		//start the new film | ||||
| 		    		FilmTabelDataType nextFilm = dbController.getNextEpisode(film.getTitle(), episode + 1); | ||||
| 		    		if (nextFilm != null) { | ||||
| //		    			System.out.println("next episode is: " + nextFilm.getStreamUrl()); | ||||
| 			    		mediaPlayer.stop(); | ||||
| 			    		player.playNewFilm(nextFilm); | ||||
| 			    		autoplay = true; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user