diff --git a/res/values/strings.xml b/res/values/strings.xml
index 22e9b3878..7d8b218a7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -152,7 +152,7 @@
Revoke access
Revoke the access permission to your flattr account for this app.
Auto-enqueue
- Add an episode to the queue after it has been downloaded.
+ Add an episode to the queue when you start to download it.
Display only episodes
Display only items which also have an episode.
User Interface
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index 07b4ae6f7..a3ab901f9 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -10,6 +10,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import de.danoeh.antennapod.AppConfig;
+import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.activity.AudioplayerActivity;
import de.danoeh.antennapod.asynctask.DownloadStatus;
import de.danoeh.antennapod.service.PlaybackService;
@@ -25,6 +26,7 @@ import android.os.AsyncTask;
import android.os.Debug;
import android.os.Handler;
import android.os.Message;
+import android.preference.PreferenceManager;
import android.util.Log;
/**
@@ -368,14 +370,28 @@ public class FeedManager {
}
public void downloadAllItemsInQueue(final Context context) {
- DownloadRequester requester = DownloadRequester.getInstance();
- for (FeedItem item : queue) {
+ if (!queue.isEmpty()) {
+ downloadFeedItem(context, queue.toArray(new FeedItem[queue.size()]));
+ }
+ }
+
+ public void downloadFeedItem(final Context context, FeedItem... items) {
+ boolean autoQueue = PreferenceManager.getDefaultSharedPreferences(
+ context.getApplicationContext()).getBoolean(
+ PodcastApp.PREF_AUTO_QUEUE, true);
+ List addToQueue = new ArrayList();
+
+ for (FeedItem item : items) {
if (item.getMedia() != null
&& !requester.isDownloadingFile(item.getMedia())
&& !item.getMedia().isDownloaded()) {
requester.downloadMedia(context, item.getMedia());
+ addToQueue.add(item);
}
}
+ if (autoQueue) {
+ addQueueItem(context, addToQueue.toArray(new FeedItem[addToQueue.size()]));
+ }
}
public void enqueueAllNewItems(final Context context) {
diff --git a/src/de/danoeh/antennapod/service/download/DownloadService.java b/src/de/danoeh/antennapod/service/download/DownloadService.java
index 734fab1ac..25cc1ee5a 100644
--- a/src/de/danoeh/antennapod/service/download/DownloadService.java
+++ b/src/de/danoeh/antennapod/service/download/DownloadService.java
@@ -694,24 +694,7 @@ public class DownloadService extends Service {
saveDownloadStatus(status);
sendDownloadHandledIntent(DOWNLOAD_TYPE_MEDIA);
manager.setFeedMedia(DownloadService.this, media);
- boolean autoQueue = PreferenceManager.getDefaultSharedPreferences(
- getApplicationContext()).getBoolean(
- PodcastApp.PREF_AUTO_QUEUE, true);
-
- if (!manager.isInQueue(media.getItem())) {
- // Auto-queue
- if (autoQueue) {
- if (AppConfig.DEBUG)
- Log.d(TAG, "Autoqueue is enabled. Adding item to queue");
- manager.addQueueItem(DownloadService.this, media.getItem());
- } else {
- if (AppConfig.DEBUG)
- Log.d(TAG, "Autoqueue is disabled");
- }
- } else {
- if (AppConfig.DEBUG)
- Log.d(TAG, "Item is already in queue");
- }
+
downloadsBeingHandled -= 1;
queryDownloads();
}
diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java
index f1dd13dab..1120f8072 100644
--- a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java
+++ b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java
@@ -69,7 +69,7 @@ public class FeedItemMenuHandler {
FeedManager manager = FeedManager.getInstance();
switch (item.getItemId()) {
case R.id.download_item:
- requester.downloadMedia(context, selectedItem.getMedia());
+ manager.downloadFeedItem(context, selectedItem);
break;
case R.id.play_item:
manager.playMedia(context, selectedItem.getMedia(), true, true,