diff options
author | ByteHamster <info@bytehamster.com> | 2022-11-05 13:09:23 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-11-05 13:19:41 +0100 |
commit | 323149642a46af75e091b9980f08151b484d0155 (patch) | |
tree | 6e0a60ac2bfb62d27df877e29f8b8fa6ac934afb /core/src/main | |
parent | d08b9e196e27b2d4454281a1fb57b8bc697afb63 (diff) | |
download | AntennaPod-323149642a46af75e091b9980f08151b484d0155.zip |
Decouple FeedItemUtil and PlaybackStatus
Diffstat (limited to 'core/src/main')
3 files changed, 25 insertions, 17 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java b/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java index c410376c2..5e1e1127a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java @@ -10,10 +10,10 @@ import java.util.List; import de.danoeh.antennapod.core.service.download.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.service.download.DownloadService; +import de.danoeh.antennapod.core.util.PlaybackStatus; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.core.util.PowerUtils; @@ -68,7 +68,8 @@ public class AutomaticDownloadAlgorithm { Iterator<FeedItem> it = candidates.iterator(); while (it.hasNext()) { FeedItem item = it.next(); - if (!item.isAutoDownloadable(System.currentTimeMillis()) || FeedItemUtil.isPlaying(item.getMedia()) + if (!item.isAutoDownloadable(System.currentTimeMillis()) + || PlaybackStatus.isPlaying(item.getMedia()) || item.getFeed().isLocalFeed()) { it.remove(); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java b/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java index 82c132dc1..e6f6654ca 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java @@ -75,19 +75,4 @@ public class FeedItemUtil { int smartMarkAsPlayedSecs = UserPreferences.getSmartMarkAsPlayedSecs(); return media.getDuration() > 0 && media.getPosition() >= media.getDuration() - smartMarkAsPlayedSecs * 1000; } - - /** - * Reads playback preferences to determine whether this FeedMedia object is - * currently being played and the current player status is playing. - */ - public static boolean isCurrentlyPlaying(FeedMedia media) { - return isPlaying(media) && PlaybackService.isRunning - && ((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING)); - } - - public static boolean isPlaying(FeedMedia media) { - return PlaybackPreferences.getCurrentlyPlayingMediaType() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA - && media != null - && PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == media.getId(); - } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/PlaybackStatus.java b/core/src/main/java/de/danoeh/antennapod/core/util/PlaybackStatus.java new file mode 100644 index 000000000..3c07d325b --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/util/PlaybackStatus.java @@ -0,0 +1,22 @@ +package de.danoeh.antennapod.core.util; + +import de.danoeh.antennapod.core.preferences.PlaybackPreferences; +import de.danoeh.antennapod.core.service.playback.PlaybackService; +import de.danoeh.antennapod.model.feed.FeedMedia; + +public abstract class PlaybackStatus { + /** + * Reads playback preferences to determine whether this FeedMedia object is + * currently being played and the current player status is playing. + */ + public static boolean isCurrentlyPlaying(FeedMedia media) { + return isPlaying(media) && PlaybackService.isRunning + && ((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING)); + } + + public static boolean isPlaying(FeedMedia media) { + return PlaybackPreferences.getCurrentlyPlayingMediaType() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA + && media != null + && PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == media.getId(); + } +} |