Search in sources :

Example 11 with LongList

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());
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) LongList(de.danoeh.antennapod.core.util.LongList)

Example 12 with LongList

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) LongList(de.danoeh.antennapod.core.util.LongList) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException)

Example 13 with LongList

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));
    }
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) LongList(de.danoeh.antennapod.core.util.LongList)

Aggregations

LongList (de.danoeh.antennapod.core.util.LongList)13 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)5 ArrayList (java.util.ArrayList)3 Cursor (android.database.Cursor)2 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 View (android.view.View)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 DefaultActionButtonCallback (de.danoeh.antennapod.adapter.DefaultActionButtonCallback)1 QueueEvent (de.danoeh.antennapod.core.event.QueueEvent)1 FeedImage (de.danoeh.antennapod.core.feed.FeedImage)1 DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)1