diff --git a/src/main/java/eu/over9000/skadi/ui/HandlerControlButton.java b/src/main/java/eu/over9000/skadi/ui/HandlerControlButton.java index 23fbc3e..9ea342f 100644 --- a/src/main/java/eu/over9000/skadi/ui/HandlerControlButton.java +++ b/src/main/java/eu/over9000/skadi/ui/HandlerControlButton.java @@ -87,21 +87,19 @@ public void setDisable(final boolean b) { openChat.setDisable(b); } - public void resetQualities() { + public void resetQualities(final Channel candidate) { openStream.getItems().clear(); openStream.getItems().add(worstItem); - final Channel candidate = table.getSelectionModel().getSelectedItem(); if ((candidate != null) && (candidate.isOnline() != null) && candidate.isOnline()) { final QualityRetrievalService service = new QualityRetrievalService(this::openStreamWithQuality, candidate); service.setOnSucceeded(event -> { - if (candidate.equals(table.getSelectionModel().getSelectedItem())) { - openStream.getItems().clear(); - openStream.getItems().addAll(service.getValue()); - openStream.getItems().add(new SeparatorMenuItem()); - openStream.getItems().add(worstItem); - } + openStream.getItems().clear(); + openStream.getItems().addAll(service.getValue()); + openStream.getItems().add(new SeparatorMenuItem()); + openStream.getItems().add(worstItem); + }); service.start(); } diff --git a/src/main/java/eu/over9000/skadi/ui/MainWindow.java b/src/main/java/eu/over9000/skadi/ui/MainWindow.java index 07c5831..65bbeac 100644 --- a/src/main/java/eu/over9000/skadi/ui/MainWindow.java +++ b/src/main/java/eu/over9000/skadi/ui/MainWindow.java @@ -490,10 +490,7 @@ private void setupTable() { table.setItems(sortedChannelList); table.getSelectionModel().selectedItemProperty().addListener((obs, oldV, newV) -> { - details.setDisable(newV == null); - remove.setDisable(newV == null); - chatAndStreamButton.setDisable(newV == null); - chatAndStreamButton.resetQualities(); + onSelection(newV); if ((newV == null) && splitPane.getItems().contains(detailPane)) { doDetailSlide(false); } @@ -515,6 +512,13 @@ private void setupTable() { }); } + public void onSelection(final Channel channel) { + details.setDisable(channel == null); + remove.setDisable(channel == null); + chatAndStreamButton.setDisable(channel == null); + chatAndStreamButton.resetQualities(channel); + } + public void openDetailPage(final Channel channel) { if (channel == null) { return; diff --git a/src/main/java/eu/over9000/skadi/ui/cells/ChannelGridCell.java b/src/main/java/eu/over9000/skadi/ui/cells/ChannelGridCell.java index 75d4566..b5faec0 100644 --- a/src/main/java/eu/over9000/skadi/ui/cells/ChannelGridCell.java +++ b/src/main/java/eu/over9000/skadi/ui/cells/ChannelGridCell.java @@ -89,6 +89,7 @@ public ChannelGridCell(final ChannelGrid grid, final MainWindow mainWindow) { } if (event.getButton() == MouseButton.PRIMARY) { if (event.getClickCount() == 1) { + mainWindow.onSelection(getItem()); updateSelected(true); grid.select(getItem()); grid.updateItems();