Search in sources :

Example 1 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class PlaybackHistoryFragment method onEventMainThread.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(FeedItemEvent event) {
    Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]");
    if (playbackHistory == null) {
        return;
    } else if (adapter == null) {
        loadItems();
        return;
    }
    for (int i = 0, size = event.items.size(); i < size; i++) {
        FeedItem item = event.items.get(i);
        int pos = FeedItemUtil.indexOfItemWithId(playbackHistory, item.getId());
        if (pos >= 0) {
            playbackHistory.remove(pos);
            playbackHistory.add(pos, item);
            adapter.notifyItemChangedCompat(pos);
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 2 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class FeedItemlistFragment method onEventMainThread.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(FeedItemEvent event) {
    Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]");
    if (feed == null || feed.getItems() == null) {
        return;
    } else if (adapter == null) {
        loadItems();
        return;
    }
    for (int i = 0, size = event.items.size(); i < size; i++) {
        FeedItem item = event.items.get(i);
        int pos = FeedItemUtil.indexOfItemWithId(feed.getItems(), item.getId());
        if (pos >= 0) {
            feed.getItems().remove(pos);
            feed.getItems().add(pos, item);
            adapter.notifyItemChangedCompat(pos);
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 3 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class EpisodeMultiSelectActionHandler method deleteChecked.

private void deleteChecked() {
    int countHasMedia = 0;
    for (FeedItem feedItem : selectedItems) {
        if (feedItem.hasMedia() && feedItem.getMedia().isDownloaded()) {
            countHasMedia++;
            DBWriter.deleteFeedMediaOfItem(activity, feedItem.getMedia().getId());
        }
    }
    showMessage(R.plurals.deleted_multi_episode_batch_label, countHasMedia);
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem)

Example 4 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class EpisodeMultiSelectActionHandler method downloadChecked.

private void downloadChecked() {
    // download the check episodes in the same order as they are currently displayed
    List<DownloadRequest> requests = new ArrayList<>();
    for (FeedItem episode : selectedItems) {
        if (episode.hasMedia() && !episode.getFeed().isLocalFeed()) {
            requests.add(DownloadRequestCreator.create(episode.getMedia()).build());
        }
    }
    DownloadService.download(activity, true, requests.toArray(new DownloadRequest[0]));
    showMessage(R.plurals.downloading_batch_label, requests.size());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ArrayList(java.util.ArrayList) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest)

Example 5 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class EpisodeMultiSelectActionHandler method queueChecked.

private void queueChecked() {
    // Check if an episode actually contains any media files before adding it to queue
    LongList toQueue = new LongList(selectedItems.size());
    for (FeedItem episode : selectedItems) {
        if (episode.hasMedia()) {
            toQueue.add(episode.getId());
        }
    }
    DBWriter.addQueueItem(activity, true, toQueue.toArray());
    showMessage(R.plurals.added_to_queue_batch_label, toQueue.size());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) LongList(de.danoeh.antennapod.core.util.LongList)

Aggregations

FeedItem (de.danoeh.antennapod.model.feed.FeedItem)178 Feed (de.danoeh.antennapod.model.feed.Feed)74 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)48 Date (java.util.Date)47 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)46 File (java.io.File)26 Cursor (android.database.Cursor)20 NonNull (androidx.annotation.NonNull)15 Nullable (androidx.annotation.Nullable)11 Subscribe (org.greenrobot.eventbus.Subscribe)9 Intent (android.content.Intent)7 FeedFilter (de.danoeh.antennapod.model.feed.FeedFilter)7 View (android.view.View)6 LongList (de.danoeh.antennapod.core.util.LongList)6 SQLException (android.database.SQLException)5 Playable (de.danoeh.antennapod.model.playback.Playable)5 EpisodeAction (de.danoeh.antennapod.net.sync.model.EpisodeAction)5 ExecutionException (java.util.concurrent.ExecutionException)5 FeedItemPubdateComparator (de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator)4