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:
parent
b5256ddaa8
commit
27cce4fc4f
|
@ -493,15 +493,16 @@ public class MainWindowController {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
||||||
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
|
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
|
||||||
indexList = filmsList.indexOf(filmsTreeTable.getSelectionModel().getSelectedItem().getValue());
|
|
||||||
last = indexTable - 1;
|
last = indexTable - 1;
|
||||||
next = indexTable + 1;
|
next = indexTable + 1;
|
||||||
title = columnTitle.getCellData(indexTable); // get name of selected item
|
title = columnTitle.getCellData(indexTable); // get name of selected item
|
||||||
streamUrl = columnStreamUrl.getCellData(indexTable); // get file path of selected item
|
streamUrl = columnStreamUrl.getCellData(indexTable); // get file path of selected item
|
||||||
|
|
||||||
System.out.println("index table: " + indexTable);
|
for (FilmTabelDataType helpData : filmsList) {
|
||||||
System.out.println("index list: " + indexList);
|
if (helpData.getStreamUrl().equals(streamUrl)) {
|
||||||
System.out.println(title);
|
indexList = filmsList.indexOf(helpData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (filmsList.get(indexList).getCached()) {
|
if (filmsList.get(indexList).getCached()) {
|
||||||
LOGGER.info("loading from cache: " + title);
|
LOGGER.info("loading from cache: " + title);
|
||||||
|
@ -1072,6 +1073,10 @@ public class MainWindowController {
|
||||||
this.bundle = bundle;
|
this.bundle = bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TreeTableView<FilmTabelDataType> getFilmsTreeTable() {
|
||||||
|
return filmsTreeTable;
|
||||||
|
}
|
||||||
|
|
||||||
public TextFlow getTextFlow() {
|
public TextFlow getTextFlow() {
|
||||||
return textFlow;
|
return textFlow;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,22 +214,22 @@ public class DBController {
|
||||||
* @param streamUrl of the film
|
* @param streamUrl of the film
|
||||||
* @param index of the film in LocalFilms list
|
* @param index of the film in LocalFilms list
|
||||||
*/
|
*/
|
||||||
public void refresh(String streamUrl, int index) {
|
public void refresh(String streamUrl, int indexList) {
|
||||||
// FIXME we need to refresh the entry in the table as well, else indexOf for indexList won't work
|
|
||||||
LOGGER.info("refresh ...");
|
LOGGER.info("refresh ...");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE streamUrl = \"" + streamUrl + "\";");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE streamUrl = \"" + streamUrl + "\";");
|
||||||
|
|
||||||
if (rs.getInt("rating") == 1) {
|
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.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_black)));
|
rs.getBoolean("cached"), new ImageView(favorite_black)));
|
||||||
} else {
|
} 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.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
|
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -448,8 +448,7 @@ public class DBController {
|
||||||
LOGGER.error("Ups! an error occured!", e);
|
LOGGER.error("Ups! an error occured!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME see fixme at refresh()
|
refresh(streamUrl, mainWindowController.getIndexList());
|
||||||
// refresh(streamUrl, mainWindowController.getIndexList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue