summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PauseActionButton.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java3
-rw-r--r--app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java8
-rw-r--r--app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java4
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java15
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/PlaybackStatus.java22
9 files changed, 39 insertions, 30 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java
index 5581ca0c6..3b3567789 100644
--- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java
+++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java
@@ -8,10 +8,10 @@ import androidx.annotation.StringRes;
import android.view.View;
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.FeedMedia;
import de.danoeh.antennapod.core.preferences.UserPreferences;
-import de.danoeh.antennapod.core.util.FeedItemUtil;
public abstract class ItemActionButton {
FeedItem item;
@@ -40,7 +40,7 @@ public abstract class ItemActionButton {
}
final boolean isDownloadingMedia = DownloadService.isDownloadingFile(media.getDownload_url());
- if (FeedItemUtil.isCurrentlyPlaying(media)) {
+ if (PlaybackStatus.isCurrentlyPlaying(media)) {
return new PauseActionButton(item);
} else if (item.getFeed().isLocalFeed()) {
return new PlayLocalActionButton(item);
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PauseActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PauseActionButton.java
index 5e9a2e9f3..90025d9a2 100644
--- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PauseActionButton.java
+++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PauseActionButton.java
@@ -6,9 +6,9 @@ import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
+import de.danoeh.antennapod.core.util.PlaybackStatus;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
-import de.danoeh.antennapod.core.util.FeedItemUtil;
public class PauseActionButton extends ItemActionButton {
@@ -35,7 +35,7 @@ public class PauseActionButton extends ItemActionButton {
return;
}
- if (FeedItemUtil.isCurrentlyPlaying(media)) {
+ if (PlaybackStatus.isCurrentlyPlaying(media)) {
context.sendBroadcast(MediaButtonReceiver.createIntent(context, KeyEvent.KEYCODE_MEDIA_PAUSE));
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java
index c80545bb2..3204f2e76 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java
@@ -41,6 +41,7 @@ import de.danoeh.antennapod.core.event.DownloadEvent;
import de.danoeh.antennapod.core.event.DownloaderUpdate;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.core.service.download.DownloadService;
+import de.danoeh.antennapod.core.util.PlaybackStatus;
import de.danoeh.antennapod.event.FeedItemEvent;
import de.danoeh.antennapod.event.PlayerStatusEvent;
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
@@ -54,7 +55,6 @@ import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.util.DateFormatter;
-import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.ui.common.CircularProgressBar;
import de.danoeh.antennapod.ui.common.ThemeUtils;
import de.danoeh.antennapod.core.util.playback.PlaybackController;
@@ -334,7 +334,7 @@ public class ItemFragment extends Fragment {
txtvDuration.setContentDescription(
Converter.getDurationStringLocalized(getContext(), media.getDuration()));
}
- if (FeedItemUtil.isCurrentlyPlaying(media)) {
+ if (PlaybackStatus.isCurrentlyPlaying(media)) {
actionButton1 = new PauseActionButton(item);
} else if (item.getFeed().isLocalFeed()) {
actionButton1 = new PlayLocalActionButton(item);
diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java
index c52db0500..e5c5a0c35 100644
--- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java
@@ -23,6 +23,7 @@ import de.danoeh.antennapod.core.sync.SynchronizationSettings;
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.core.util.IntentUtils;
+import de.danoeh.antennapod.core.util.PlaybackStatus;
import de.danoeh.antennapod.core.util.ShareUtils;
import de.danoeh.antennapod.dialog.ShareDialog;
import de.danoeh.antennapod.model.feed.FeedItem;
@@ -52,7 +53,7 @@ public class FeedItemMenuHandler {
return false;
}
final boolean hasMedia = selectedItem.getMedia() != null;
- final boolean isPlaying = hasMedia && FeedItemUtil.isPlaying(selectedItem.getMedia());
+ final boolean isPlaying = hasMedia && PlaybackStatus.isPlaying(selectedItem.getMedia());
final boolean isInQueue = selectedItem.isTagged(FeedItem.TAG_QUEUE);
final boolean fileDownloaded = hasMedia && selectedItem.getMedia().fileExists();
final boolean isFavorite = selectedItem.isTagged(FeedItem.TAG_FAVORITE);
diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java
index 8e5f48324..4b83f70ef 100644
--- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java
+++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java
@@ -23,6 +23,7 @@ import de.danoeh.antennapod.adapter.CoverLoader;
import de.danoeh.antennapod.adapter.actionbutton.ItemActionButton;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.core.service.download.DownloadService;
+import de.danoeh.antennapod.core.util.PlaybackStatus;
import de.danoeh.antennapod.core.util.download.MediaSizeLoader;
import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
import de.danoeh.antennapod.core.util.DateFormatter;
@@ -32,7 +33,6 @@ import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.Converter;
-import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.core.util.NetworkUtils;
import de.danoeh.antennapod.model.playback.Playable;
import de.danoeh.antennapod.ui.common.CircularProgressBar;
@@ -140,7 +140,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
isVideo.setVisibility(media.getMediaType() == MediaType.VIDEO ? View.VISIBLE : View.GONE);
duration.setVisibility(media.getDuration() > 0 ? View.VISIBLE : View.GONE);
- if (FeedItemUtil.isCurrentlyPlaying(media)) {
+ if (PlaybackStatus.isCurrentlyPlaying(media)) {
itemView.setBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.currently_playing_background));
} else {
itemView.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground));
@@ -159,7 +159,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
duration.setText(Converter.getDurationStringLong(media.getDuration()));
duration.setContentDescription(activity.getString(R.string.chapter_duration,
Converter.getDurationStringLocalized(activity, media.getDuration())));
- if (FeedItemUtil.isPlaying(item.getMedia()) || item.isInProgress()) {
+ if (PlaybackStatus.isPlaying(item.getMedia()) || item.isInProgress()) {
int progress = (int) (100.0 * media.getPosition() / media.getDuration());
int remainingTime = Math.max(media.getDuration() - media.getPosition(), 0);
progressBar.setProgress(progress);
@@ -247,7 +247,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
}
public boolean isCurrentlyPlayingItem() {
- return item.getMedia() != null && FeedItemUtil.isCurrentlyPlaying(item.getMedia());
+ return item.getMedia() != null && PlaybackStatus.isCurrentlyPlaying(item.getMedia());
}
public void notifyPlaybackPositionUpdated(PlaybackPositionEvent event) {
diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java
index f2d8e628c..60422d74f 100644
--- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java
+++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java
@@ -15,7 +15,7 @@ import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.core.service.download.DownloadService;
import de.danoeh.antennapod.core.util.DateFormatter;
-import de.danoeh.antennapod.core.util.FeedItemUtil;
+import de.danoeh.antennapod.core.util.PlaybackStatus;
import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
@@ -96,7 +96,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
}
public boolean isCurrentlyPlayingItem() {
- return item != null && item.getMedia() != null && FeedItemUtil.isCurrentlyPlaying(item.getMedia());
+ return item != null && item.getMedia() != null && PlaybackStatus.isCurrentlyPlaying(item.getMedia());
}
public void notifyPlaybackPositionUpdated(PlaybackPositionEvent event) {
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();
+ }
+}