diff options
author | ByteHamster <info@bytehamster.com> | 2020-04-10 21:56:44 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-04-10 21:56:44 +0200 |
commit | c24761806e87a3c1a9fe6dc5b6342034d2678408 (patch) | |
tree | 6a849988fe231b9fe2194c3eb8814ac660c68dbf /core/src | |
parent | a35ecaa74bd9392f9e7e513522aee8e1601e78cf (diff) | |
download | AntennaPod-c24761806e87a3c1a9fe6dc5b6342034d2678408.zip |
Allow to stop previewed episode
Diffstat (limited to 'core/src')
4 files changed, 26 insertions, 23 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java index 175f8e77b..a41b04b53 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java @@ -209,7 +209,7 @@ public class FeedMedia extends FeedFile implements Playable { * currently being played. */ public boolean isPlaying() { - return PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA + return PlaybackPreferences.getCurrentlyPlayingMediaType() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA && PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == id; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java index 4e2233407..a4612d857 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java @@ -33,14 +33,16 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference * Contains the id of the currently playing FeedMedia object or * NO_MEDIA_PLAYING if the currently playing media is no FeedMedia object. */ - private static final String PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID = "de.danoeh.antennapod.preferences.lastPlayedFeedMediaId"; + private static final String PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID + = "de.danoeh.antennapod.preferences.lastPlayedFeedMediaId"; /** * Type of the media object that is currently being played. This preference * is set to NO_MEDIA_PLAYING after playback has been completed and is set * as soon as the 'play' button is pressed. */ - private static final String PREF_CURRENTLY_PLAYING_MEDIA = "de.danoeh.antennapod.preferences.currentlyPlayingMedia"; + private static final String PREF_CURRENTLY_PLAYING_MEDIA_TYPE + = "de.danoeh.antennapod.preferences.currentlyPlayingMedia"; /** * True if last played media was streamed. @@ -61,7 +63,8 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference * A temporary playback speed which overrides the per-feed playback speed for the currently playing * media. Considered unset if set to SPEED_USE_GLOBAL; */ - private static final String PREF_CURRENTLY_PLAYING_TEMPORARY_PLAYBACK_SPEED = "de.danoeh.antennapod.preferences.temporaryPlaybackSpeed"; + private static final String PREF_CURRENTLY_PLAYING_TEMPORARY_PLAYBACK_SPEED + = "de.danoeh.antennapod.preferences.temporaryPlaybackSpeed"; /** @@ -102,21 +105,21 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference } } - public static long getCurrentlyPlayingMedia() { - return prefs.getLong(PREF_CURRENTLY_PLAYING_MEDIA, NO_MEDIA_PLAYING); - } + public static long getCurrentlyPlayingMediaType() { + return prefs.getLong(PREF_CURRENTLY_PLAYING_MEDIA_TYPE, NO_MEDIA_PLAYING); + } - public static long getCurrentlyPlayingFeedMediaId() { - return prefs.getLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING); - } + public static long getCurrentlyPlayingFeedMediaId() { + return prefs.getLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING); + } - public static boolean getCurrentEpisodeIsStream() { - return prefs.getBoolean(PREF_CURRENT_EPISODE_IS_STREAM, true); - } + public static boolean getCurrentEpisodeIsStream() { + return prefs.getBoolean(PREF_CURRENT_EPISODE_IS_STREAM, true); + } - public static boolean getCurrentEpisodeIsVideo() { - return prefs.getBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, false); - } + public static boolean getCurrentEpisodeIsVideo() { + return prefs.getBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, false); + } public static int getCurrentPlayerStatus() { return prefs.getInt(PREF_CURRENT_PLAYER_STATUS, PLAYER_STATUS_OTHER); @@ -128,7 +131,7 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference public static void writeNoMediaPlaying() { SharedPreferences.Editor editor = prefs.edit(); - editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA, NO_MEDIA_PLAYING); + editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA_TYPE, NO_MEDIA_PLAYING); editor.putLong(PREF_CURRENTLY_PLAYING_FEED_ID, NO_MEDIA_PLAYING); editor.putLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING); editor.putInt(PREF_CURRENT_PLAYER_STATUS, PLAYER_STATUS_OTHER); @@ -142,13 +145,13 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference if (playable == null) { writeNoMediaPlaying(); } else { - editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA, playable.getPlayableType()); + editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA_TYPE, playable.getPlayableType()); editor.putBoolean(PREF_CURRENT_EPISODE_IS_STREAM, stream); editor.putBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, playable.getMediaType() == MediaType.VIDEO); if (playable instanceof FeedMedia) { - FeedMedia fMedia = (FeedMedia) playable; - editor.putLong(PREF_CURRENTLY_PLAYING_FEED_ID, fMedia.getItem().getFeed().getId()); - editor.putLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, fMedia.getId()); + FeedMedia feedMedia = (FeedMedia) playable; + editor.putLong(PREF_CURRENTLY_PLAYING_FEED_ID, feedMedia.getItem().getFeed().getId()); + editor.putLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, feedMedia.getId()); } else { editor.putLong(PREF_CURRENTLY_PLAYING_FEED_ID, NO_MEDIA_PLAYING); editor.putLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java index 378c47faf..24aabf212 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java @@ -188,7 +188,7 @@ public interface Playable extends Parcelable, */ @Nullable public static Playable createInstanceFromPreferences(Context context) { - long currentlyPlayingMedia = PlaybackPreferences.getCurrentlyPlayingMedia(); + long currentlyPlayingMedia = PlaybackPreferences.getCurrentlyPlayingMediaType(); if (currentlyPlayingMedia != PlaybackPreferences.NO_MEDIA_PLAYING) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); return PlayableUtils.createInstanceFromPreferences(context, diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java index c39121564..ca09cda4b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java @@ -282,7 +282,7 @@ public class RemoteMedia implements Playable { dest.writeString(imageUrl); dest.writeString(feedLink); dest.writeString(mimeType); - dest.writeLong(pubDate.getTime()); + dest.writeLong((pubDate != null) ? pubDate.getTime() : 0); dest.writeString(notes); dest.writeInt(duration); dest.writeInt(position); |