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;
}
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;
}
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());
}
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());
}
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();
}
}
Aggregations