Browse Source

fixed refreshing bug

* fixed refreshing bug, like and dislike are working again as well as loading the cache after you saved the data for the first time
pull/22/head
Jannik 4 years ago
parent
commit
27cce4fc4f
  1. 15
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java
  2. 11
      src/main/java/kellerkinder/HomeFlix/controller/DBController.java

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

@ -493,15 +493,16 @@ public class MainWindowController {
@Override
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
indexList = filmsList.indexOf(filmsTreeTable.getSelectionModel().getSelectedItem().getValue());
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
System.out.println("index table: " + indexTable);
System.out.println("index list: " + indexList);
System.out.println(title);
for (FilmTabelDataType helpData : filmsList) {
if (helpData.getStreamUrl().equals(streamUrl)) {
indexList = filmsList.indexOf(helpData);
}
}
if (filmsList.get(indexList).getCached()) {
LOGGER.info("loading from cache: " + title);
@ -1072,6 +1073,10 @@ public class MainWindowController {
this.bundle = bundle;
}
public TreeTableView<FilmTabelDataType> getFilmsTreeTable() {
return filmsTreeTable;
}
public TextFlow getTextFlow() {
return textFlow;
}

11
src/main/java/kellerkinder/HomeFlix/controller/DBController.java

@ -214,22 +214,22 @@ public class DBController {
* @param streamUrl of the film
* @param index of the film in LocalFilms list
*/
public void refresh(String streamUrl, int index) {
// FIXME we need to refresh the entry in the table as well, else indexOf for indexList won't work
public void refresh(String streamUrl, int indexList) {
LOGGER.info("refresh ...");
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE streamUrl = \"" + streamUrl + "\";");
if (rs.getInt("rating") == 1) {
mainWindowController.getFilmsList().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
mainWindowController.getFilmsList().set(indexList, new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
rs.getBoolean("cached"), new ImageView(favorite_black)));
} else {
mainWindowController.getFilmsList().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
mainWindowController.getFilmsList().set(indexList, new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
}
rs.close();
stmt.close();
} catch (Exception e) {
@ -448,8 +448,7 @@ public class DBController {
LOGGER.error("Ups! an error occured!", e);
}
// FIXME see fixme at refresh()
// refresh(streamUrl, mainWindowController.getIndexList());
refresh(streamUrl, mainWindowController.getIndexList());
}
/**

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