use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class DBWriter method addQueueItem.
public static Future<?> addQueueItem(final Context context, final FeedItem... items) {
LongList itemIds = new LongList(items.length);
for (FeedItem item : items) {
itemIds.add(item.getId());
item.addTag(FeedItem.TAG_QUEUE);
}
return addQueueItem(context, false, itemIds.toArray());
}
use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class DefaultActionButtonCallback method confirmMobileDownload.
private void confirmMobileDownload(final Context context, final FeedItem item) {
MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
builder.title(R.string.confirm_mobile_download_dialog_title).content(R.string.confirm_mobile_download_dialog_message).positiveText(context.getText(R.string.confirm_mobile_download_dialog_enable_temporarily)).onPositive((dialog, which) -> {
allowMobileDownloadsTimestamp = System.currentTimeMillis();
try {
DBTasks.downloadFeedItems(context, item);
Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());
}
});
LongList queueIds = DBReader.getQueueIDList();
if (!queueIds.contains(item.getId())) {
builder.content(R.string.confirm_mobile_download_dialog_message_not_in_queue).neutralText(R.string.confirm_mobile_download_dialog_only_add_to_queue).onNeutral((dialog, which) -> {
onlyAddToQueueTimeStamp = System.currentTimeMillis();
DBWriter.addQueueItem(context, item);
Toast.makeText(context, R.string.added_to_queue_label, Toast.LENGTH_SHORT).show();
});
}
builder.show();
}
use of de.danoeh.antennapod.core.util.LongList in project AntennaPod by AntennaPod.
the class DBReaderTest method testGetQueueIDList.
public void testGetQueueIDList() {
final int numItems = 10;
List<FeedItem> queue = saveQueue(numItems);
LongList ids = DBReader.getQueueIDList();
assertNotNull(ids);
assertTrue(queue.size() == ids.size());
for (int i = 0; i < queue.size(); i++) {
assertTrue(ids.get(i) != 0);
assertTrue(queue.get(i).getId() == ids.get(i));
}
}
Aggregations