Added menu item to download all items in the queue

This commit is contained in:
daniel oeh 2012-09-21 13:07:44 +02:00
parent d71831e7ad
commit ea7b7bbb73
3 changed files with 19 additions and 1 deletions

View File

@ -9,5 +9,6 @@
<item type="id" name="deselect_all_item"/>
<item type="id" name="search_item"/>
<item name="enqueue_all_item" type="id"/>
<item name="download_all_item" type="id"/>
</resources>

View File

@ -367,6 +367,17 @@ public class FeedManager {
}
public void downloadAllItemsInQueue(final Context context) {
DownloadRequester requester = DownloadRequester.getInstance();
for (FeedItem item : queue) {
if (item.getMedia() != null
&& !requester.isDownloadingFile(item.getMedia())
&& !item.getMedia().isDownloaded()) {
requester.downloadMedia(context, item.getMedia());
}
}
}
public void enqueueAllNewItems(final Context context) {
if (!unreadItems.isEmpty()) {
addQueueItem(context,

View File

@ -16,7 +16,7 @@ import de.danoeh.antennapod.R;
public class QueueFragment extends ItemlistFragment {
private static final String TAG = "QueueFragment";
public QueueFragment() {
super(FeedManager.getInstance().getQueue(), true);
}
@ -62,6 +62,8 @@ public class QueueFragment extends ItemlistFragment {
super.onCreateOptionsMenu(menu, inflater);
menu.add(Menu.NONE, R.id.clear_queue_item, Menu.NONE, getActivity()
.getString(R.string.clear_queue_label));
menu.add(Menu.NONE, R.id.download_all_item, Menu.NONE, getActivity()
.getString(R.string.download_all));
}
@Override
@ -70,6 +72,10 @@ public class QueueFragment extends ItemlistFragment {
case R.id.clear_queue_item:
manager.clearQueue(getActivity());
break;
case R.id.download_all_item:
manager.downloadAllItemsInQueue(getActivity());
fila.notifyDataSetChanged();
break;
default:
return false;
}