diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2020-03-01 01:22:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 01:22:29 +0100 |
commit | fef4fb9a6b24abdd34dce630f2197f478cae7b3d (patch) | |
tree | 2e36dcae5d08182883f9161e27d68d0ea67c2312 /app/src/main/java/de/danoeh/antennapod/adapter/actionbutton | |
parent | 809ca28ab7fb80cd5f3506492c57189f5c1bd153 (diff) | |
download | AntennaPod-fef4fb9a6b24abdd34dce630f2197f478cae7b3d.zip |
Add allow streaming dialog (#3897)
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/adapter/actionbutton')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/StreamActionButton.java | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/StreamActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/StreamActionButton.java index 3a43d3217..38b84c453 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/StreamActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/StreamActionButton.java @@ -10,7 +10,9 @@ import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.util.IntentUtils; +import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter; +import de.danoeh.antennapod.dialog.StreamingConfirmationDialog; import static de.danoeh.antennapod.core.service.playback.PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE; @@ -29,10 +31,6 @@ public class StreamActionButton extends ItemActionButton { @Override @AttrRes public int getDrawable() { - FeedMedia media = item.getMedia(); - if (media != null && media.isCurrentlyPlaying()) { - return R.attr.av_pause; - } return R.attr.action_stream; } @@ -42,23 +40,10 @@ public class StreamActionButton extends ItemActionButton { if (media == null) { return; } - - if (media.isPlaying()) { - togglePlayPause(context, media); - } else { - DBTasks.playMedia(context, media, false, true, true); - } - } - - private void togglePlayPause(Context context, FeedMedia media) { - if (media.isCurrentlyPlaying()) { - IntentUtils.sendLocalBroadcast(context, ACTION_PAUSE_PLAY_CURRENT_EPISODE); - } else { - new PlaybackServiceStarter(context, media) - .callEvenIfRunning(true) - .startWhenPrepared(true) - .shouldStream(true) - .start(); + if (!NetworkUtils.isStreamingAllowed()) { + new StreamingConfirmationDialog(context, media).show(); + return; } + DBTasks.playMedia(context, media, false, true, true); } } |