From dc239801c659e9bd3e9d17527a23a24bdbe3db62 Mon Sep 17 00:00:00 2001 From: Dennis Sheirer Date: Sun, 5 Nov 2023 05:58:32 -0500 Subject: [PATCH] #1665 Add option to refresh available streams from broadcastify in playlist editor's streaming tab. --- .../gui/control/IntegerTextField.java | 2 +- .../playlist/streaming/StreamingEditor.java | 56 +++++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/github/dsheirer/gui/control/IntegerTextField.java b/src/main/java/io/github/dsheirer/gui/control/IntegerTextField.java index 8768e68b0..ef94125ec 100644 --- a/src/main/java/io/github/dsheirer/gui/control/IntegerTextField.java +++ b/src/main/java/io/github/dsheirer/gui/control/IntegerTextField.java @@ -67,7 +67,7 @@ public Integer get() //Do nothing ... we couldn't parse the value } - return null; + return 0; } /** diff --git a/src/main/java/io/github/dsheirer/gui/playlist/streaming/StreamingEditor.java b/src/main/java/io/github/dsheirer/gui/playlist/streaming/StreamingEditor.java index 102f67c26..161e39e9f 100644 --- a/src/main/java/io/github/dsheirer/gui/playlist/streaming/StreamingEditor.java +++ b/src/main/java/io/github/dsheirer/gui/playlist/streaming/StreamingEditor.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,11 @@ import io.github.dsheirer.playlist.PlaylistManager; import io.github.dsheirer.rrapi.type.UserFeedBroadcast; import io.github.dsheirer.util.ThreadPool; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -48,6 +53,7 @@ import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; +import javafx.scene.control.Tooltip; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; @@ -58,12 +64,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - /** * Editor for broadcast audio stream configurations */ @@ -75,6 +75,7 @@ public class StreamingEditor extends SplitPane private TableView mConfiguredBroadcastTableView; private MenuButton mNewButton; private Button mDeleteButton; + private Button mRefreshButton; private TabPane mTabPane; private Tab mConfigurationTab; private Tab mAliasTab; @@ -101,7 +102,7 @@ public StreamingEditor(PlaylistManager playlistManager) refreshBroadcastifyStreams(); VBox buttonsBox = new VBox(); - buttonsBox.getChildren().addAll(getNewButton(), getDeleteButton()); + buttonsBox.getChildren().addAll(getNewButton(), getDeleteButton(), getRefreshButton()); buttonsBox.setPadding(new Insets(0, 0, 0, 10)); buttonsBox.setSpacing(10); @@ -231,21 +232,16 @@ private void refreshBroadcastifyStreams() { if(mPlaylistManager.getRadioReference().availableProperty().get()) { - ThreadPool.CACHED.submit(new Runnable() - { - @Override - public void run() + ThreadPool.CACHED.submit(() -> { + try { - try - { - List feeds = mPlaylistManager.getRadioReference().getService().getUserFeeds(); - mBroadcastifyFeeds.clear(); - mBroadcastifyFeeds.addAll(feeds); - } - catch(Throwable t) - { - mLog.error("Unable to refresh broadcastify stream configuration(s)"); - } + List feeds = mPlaylistManager.getRadioReference().getService().getUserFeeds(); + mBroadcastifyFeeds.clear(); + mBroadcastifyFeeds.addAll(feeds); + } + catch(Throwable t) + { + mLog.error("Unable to refresh broadcastify stream configuration(s)"); } }); } @@ -348,6 +344,22 @@ private MenuButton getNewButton() return mNewButton; } + /** + * Refresh broadcastify feeds. + * @return button to refresh. + */ + private Button getRefreshButton() + { + if(mRefreshButton == null) + { + mRefreshButton = new Button("Refresh"); + mRefreshButton.setTooltip(new Tooltip("Refresh streams available from Broadcastify")); + mRefreshButton.setOnAction(event -> refreshBroadcastifyStreams()); + } + + return mRefreshButton; + } + private Button getDeleteButton() { if(mDeleteButton == null)