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="deselect_all_item"/>
<item type="id" name="search_item"/>
<item name="enqueue_all_item" type="id"/>
</resources>

View File

@ -55,6 +55,8 @@
<string name="remove_from_queue_label">Remove from Queue</string>
<string name="visit_website_label">Visit Website</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 -->
<string name="download_successful">Download successful</string>

View File

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

View File

@ -31,6 +31,8 @@ public class UnreadItemlistFragment extends ItemlistFragment {
super.onCreateOptionsMenu(menu, inflater);
menu.add(Menu.NONE, R.id.mark_all_read_item, Menu.NONE, getActivity()
.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
@ -44,6 +46,9 @@ public class UnreadItemlistFragment extends ItemlistFragment {
case R.id.mark_all_read_item:
manager.markAllItemsRead(getActivity());
break;
case R.id.enqueue_all_item:
manager.enqueueAllNewItems(getActivity());
break;
default:
return false;
}