Changed behavior of continuous playback

This commit is contained in:
daniel oeh 2012-10-04 13:28:09 +02:00
parent cd7cb59175
commit 243f75b65c
2 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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)