Search in sources :

Example 96 with FeedItem

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

the class ItemFragment method loadInBackground.

@Nullable
private FeedItem loadInBackground() {
    FeedItem feedItem = DBReader.getFeedItem(itemId);
    Context context = getContext();
    if (feedItem != null && context != null) {
        int duration = feedItem.getMedia() != null ? feedItem.getMedia().getDuration() : Integer.MAX_VALUE;
        DBReader.loadDescriptionOfFeedItem(feedItem);
        Timeline t = new Timeline(context, feedItem.getDescription(), duration);
        webviewData = t.processShownotes();
    }
    return feedItem;
}
Also used : Context(android.content.Context) Timeline(de.danoeh.antennapod.core.util.playback.Timeline) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Nullable(androidx.annotation.Nullable)

Example 97 with FeedItem

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

the class PlaybackServiceMediaPlayerTest method writeTestPlayable.

private Playable writeTestPlayable(String downloadUrl, String fileUrl) {
    Feed f = new Feed(0, null, "f", "l", "d", null, null, null, null, "i", null, null, "l", false);
    FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NO, VolumeAdaptionSetting.OFF, null, null);
    f.setPreferences(prefs);
    f.setItems(new ArrayList<>());
    FeedItem i = new FeedItem(0, "t", "i", "l", new Date(), FeedItem.UNPLAYED, f);
    f.getItems().add(i);
    FeedMedia media = new FeedMedia(0, i, 0, 0, 0, "audio/wav", fileUrl, downloadUrl, fileUrl != null, null, 0, 0);
    i.setMedia(media);
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    adapter.setCompleteFeed(f);
    assertTrue(media.getId() != 0);
    adapter.close();
    return media;
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) PodDBAdapter(de.danoeh.antennapod.core.storage.PodDBAdapter) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Date(java.util.Date) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 98 with FeedItem

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

the class PlaybackTest method startLocalPlayback.

protected void startLocalPlayback() {
    openNavDrawer();
    onDrawerItem(withText(R.string.episodes_label)).perform(click());
    onView(isRoot()).perform(waitForView(withText(R.string.all_episodes_short_label), 1000));
    onView(withText(R.string.all_episodes_short_label)).perform(click());
    final List<FeedItem> episodes = DBReader.getRecentlyPublishedEpisodes(0, 10, FeedItemFilter.unfiltered());
    Matcher<View> allEpisodesMatcher = allOf(withId(android.R.id.list), isDisplayed(), hasMinimumChildCount(2));
    onView(isRoot()).perform(waitForView(allEpisodesMatcher, 1000));
    onView(allEpisodesMatcher).perform(actionOnItemAtPosition(0, clickChildViewWithId(R.id.secondaryActionButton)));
    FeedMedia media = episodes.get(0).getMedia();
    Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) View(android.view.View) Espresso.onView(androidx.test.espresso.Espresso.onView) EspressoTestUtils.waitForView(de.test.antennapod.EspressoTestUtils.waitForView)

Example 99 with FeedItem

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

the class PlaybackTest method testPlayingItemAddsToQueue.

@Test
public void testPlayingItemAddsToQueue() throws Exception {
    uiTestUtils.addLocalFeedData(true);
    activityTestRule.launchActivity(new Intent());
    DBWriter.clearQueue().get();
    List<FeedItem> queue = DBReader.getQueue();
    assertEquals(0, queue.size());
    startLocalPlayback();
    Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> 1 == DBReader.getQueue().size());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Intent(android.content.Intent) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 100 with FeedItem

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

the class DBReader method getFeedMedia.

/**
 * Searches the DB for a FeedMedia of the given id.
 *
 * @param mediaId The id of the object
 * @return The found object, or null if it does not exist
 */
@Nullable
public static FeedMedia getFeedMedia(final long mediaId) {
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    try (Cursor mediaCursor = adapter.getSingleFeedMediaCursor(mediaId)) {
        if (!mediaCursor.moveToFirst()) {
            return null;
        }
        int indexFeedItem = mediaCursor.getColumnIndex(PodDBAdapter.KEY_FEEDITEM);
        long itemId = mediaCursor.getLong(indexFeedItem);
        FeedMedia media = FeedMediaCursorMapper.convert(mediaCursor);
        FeedItem item = getFeedItem(itemId);
        if (item != null) {
            media.setItem(item);
            item.setMedia(media);
        }
        return media;
    } finally {
        adapter.close();
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Cursor(android.database.Cursor) Nullable(androidx.annotation.Nullable)

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