Implemented 'enqueue all'

This commit is contained in:
daniel oeh 2012-09-21 12:57:34 +02:00
parent 0459f91299
commit d71831e7ad
4 changed files with 46 additions and 21 deletions

View File

@ -8,5 +8,6 @@
<item type="id" name="select_all_item"/> <item type="id" name="select_all_item"/>
<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"/>
</resources> </resources>

View File

@ -55,6 +55,8 @@
<string name="remove_from_queue_label">Remove from Queue</string> <string name="remove_from_queue_label">Remove from Queue</string>
<string name="visit_website_label">Visit Website</string> <string name="visit_website_label">Visit Website</string>
<string name="support_label">Flattr this</string> <string name="support_label">Flattr this</string>
<string name="enqueue_all_new">Enqueue all</string>
<string name="download_all">Download all</string>
<!-- Download messages and labels --> <!-- Download messages and labels -->
<string name="download_successful">Download successful</string> <string name="download_successful">Download successful</string>

View File

@ -367,13 +367,26 @@ public class FeedManager {
} }
public void addQueueItem(final Context context, final FeedItem item) { public void enqueueAllNewItems(final Context context) {
if (!unreadItems.isEmpty()) {
addQueueItem(context,
unreadItems.toArray(new FeedItem[unreadItems.size()]));
markAllItemsRead(context);
}
}
public void addQueueItem(final Context context, final FeedItem... items) {
if (items.length > 0) {
contentChanger.post(new Runnable() { contentChanger.post(new Runnable() {
@Override @Override
public void run() { public void run() {
for (FeedItem item : items) {
if (!queue.contains(item)) {
queue.add(item); queue.add(item);
sendQueueUpdateBroadcast(context, item); }
}
sendQueueUpdateBroadcast(context, items[0]);
} }
}); });
@ -387,6 +400,7 @@ public class FeedManager {
adapter.close(); adapter.close();
} }
}); });
}
} }
@ -971,13 +985,16 @@ public class FeedManager {
boolean successful = logCursor boolean successful = logCursor
.getInt(PodDBAdapter.KEY_SUCCESSFUL_INDEX) > 0; .getInt(PodDBAdapter.KEY_SUCCESSFUL_INDEX) > 0;
int reason = logCursor.getInt(PodDBAdapter.KEY_REASON_INDEX); int reason = logCursor.getInt(PodDBAdapter.KEY_REASON_INDEX);
String reasonDetailed = logCursor.getString(PodDBAdapter.KEY_REASON_DETAILED_INDEX); String reasonDetailed = logCursor
String title = logCursor.getString(PodDBAdapter.KEY_DOWNLOADSTATUS_TITLE_INDEX); .getString(PodDBAdapter.KEY_REASON_DETAILED_INDEX);
String title = logCursor
.getString(PodDBAdapter.KEY_DOWNLOADSTATUS_TITLE_INDEX);
Date completionDate = new Date( Date completionDate = new Date(
logCursor logCursor
.getLong(PodDBAdapter.KEY_COMPLETION_DATE_INDEX)); .getLong(PodDBAdapter.KEY_COMPLETION_DATE_INDEX));
downloadLog.add(new DownloadStatus(id, title, feedfile, feedfileType, successful, downloadLog.add(new DownloadStatus(id, title, feedfile,
reason, completionDate, reasonDetailed)); feedfileType, successful, reason, completionDate,
reasonDetailed));
} while (logCursor.moveToNext()); } while (logCursor.moveToNext());
} }

View File

@ -31,6 +31,8 @@ public class UnreadItemlistFragment extends ItemlistFragment {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
menu.add(Menu.NONE, R.id.mark_all_read_item, Menu.NONE, getActivity() menu.add(Menu.NONE, R.id.mark_all_read_item, Menu.NONE, getActivity()
.getString(R.string.mark_all_read_label)); .getString(R.string.mark_all_read_label));
menu.add(Menu.NONE, R.id.enqueue_all_item, Menu.NONE, getActivity()
.getString(R.string.enqueue_all_new));
} }
@Override @Override
@ -44,6 +46,9 @@ public class UnreadItemlistFragment extends ItemlistFragment {
case R.id.mark_all_read_item: case R.id.mark_all_read_item:
manager.markAllItemsRead(getActivity()); manager.markAllItemsRead(getActivity());
break; break;
case R.id.enqueue_all_item:
manager.enqueueAllNewItems(getActivity());
break;
default: default:
return false; return false;
} }