From 243f75b65c615f2c542642d685febf507a2241ad Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Thu, 4 Oct 2012 13:28:09 +0200 Subject: [PATCH] Changed behavior of continuous playback --- src/de/danoeh/antennapod/feed/FeedManager.java | 14 ++++++++++++++ .../danoeh/antennapod/service/PlaybackService.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index 04dc3b2a9..ba9abfe83 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -617,6 +617,20 @@ public class FeedManager { } + /** + * Return the item that comes after this item in the queue or null if this + * item is not in the queue or if this item has no successor. + */ + public FeedItem getQueueSuccessorOfItem(FeedItem item) { + if (isInQueue(item)) { + int itemIndex = queue.indexOf(item); + if (itemIndex != -1 && itemIndex < (queue.size() - 1)) { + return queue.get(itemIndex + 1); + } + } + return null; + } + /** Removes all items in queue */ public void clearQueue(final Context context) { if (AppConfig.DEBUG) diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index f184404b3..ff126e9f2 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -656,6 +656,7 @@ public class PlaybackService extends Service { media.setPosition(0); media.setPlaybackCompletionDate(new Date()); manager.markItemRead(PlaybackService.this, media.getItem(), true); + FeedItem nextItem = manager.getQueueSuccessorOfItem(media.getItem()); boolean isInQueue = manager.isInQueue(media.getItem()); if (isInQueue) { manager.removeQueueItem(PlaybackService.this, media.getItem()); @@ -676,7 +677,6 @@ public class PlaybackService extends Service { // Prepare for playing next item boolean followQueue = prefs.getBoolean( PodcastApp.PREF_FOLLOW_QUEUE, false); - FeedItem nextItem = manager.getFirstQueueItem(); boolean playNextItem = isInQueue && followQueue && nextItem != null; if (playNextItem) { if (AppConfig.DEBUG)