Add item to queue once it's downloaded

This commit is contained in:
daniel oeh 2013-03-07 16:01:14 +01:00
parent 9dec0546bd
commit 58747d227a
2 changed files with 8 additions and 7 deletions

View File

@ -570,7 +570,6 @@ public class FeedManager {
/** Downloads FeedItems if they have not been downloaded yet. */
public void downloadFeedItem(final Context context, FeedItem... items)
throws DownloadRequestException {
List<FeedItem> addToQueue = new ArrayList<FeedItem>();
for (FeedItem item : items) {
if (item.getMedia() != null
@ -591,13 +590,8 @@ public class FeedManager {
} else {
requester.downloadMedia(context, item.getMedia());
}
addToQueue.add(item);
}
}
if (UserPreferences.isAutoQueue()) {
addQueueItem(context,
addToQueue.toArray(new FeedItem[addToQueue.size()]));
}
}
/**

View File

@ -58,6 +58,7 @@ import de.danoeh.antennapod.feed.FeedImage;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.syndication.handler.FeedHandler;
@ -831,7 +832,7 @@ public class DownloadService extends Service {
} finally {
mediaplayer.release();
}
if (media.getItem().getChapters() == null) {
ChapterUtils.loadChaptersFromFileUrl(media);
if (media.getItem().getChapters() != null) {
@ -847,6 +848,12 @@ public class DownloadService extends Service {
manager.setFeedMedia(DownloadService.this, media);
}
if (UserPreferences.isAutoQueue()
&& !FeedManager.getInstance().isInQueue(media.getItem())) {
FeedManager.getInstance().addQueueItem(DownloadService.this,
media.getItem());
}
downloadsBeingHandled -= 1;
handler.post(new Runnable() {