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="deselect_all_item"/>
<item type="id" name="search_item"/> <item type="id" name="search_item"/>
<item name="enqueue_all_item" type="id"/> <item name="enqueue_all_item" type="id"/>
<item name="download_all_item" type="id"/>
</resources> </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) { public void enqueueAllNewItems(final Context context) {
if (!unreadItems.isEmpty()) { if (!unreadItems.isEmpty()) {
addQueueItem(context, addQueueItem(context,

View File

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