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
This commit is contained in:
Jannik 2018-03-08 23:01:07 +01:00
parent b5256ddaa8
commit 27cce4fc4f
2 changed files with 15 additions and 11 deletions

View File

@ -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;
}

View File

@ -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());
}
/**