use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class QueueFragment method onEventMainThread.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(FeedItemEvent event) {
Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]");
if (queue == null) {
return;
} else if (recyclerAdapter == null) {
loadItems(true);
return;
}
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(queue, item.getId());
if (pos >= 0) {
queue.remove(pos);
queue.add(pos, item);
recyclerAdapter.notifyItemChangedCompat(pos);
refreshInfoBar();
}
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class RssParserTest method testMediaContentMime.
@Test
public void testMediaContentMime() throws Exception {
File feedFile = FeedParserTestHelper.getFeedFile("feed-rss-testMediaContentMime.xml");
Feed feed = FeedParserTestHelper.runFeedParser(feedFile);
assertEquals("title", feed.getTitle());
assertEquals("http://example.com", feed.getLink());
assertEquals("This is the description", feed.getDescription());
assertEquals("http://example.com/payment", feed.getPaymentLinks().get(0).url);
assertNull(feed.getImageUrl());
assertEquals(1, feed.getItems().size());
FeedItem feedItem = feed.getItems().get(0);
// noinspection ConstantConditions
assertEquals(MediaType.VIDEO, feedItem.getMedia().getMediaType());
assertEquals("https://www.example.com/file.mp4", feedItem.getMedia().getDownload_url());
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class AtomParserTest method testAtomBasic.
@Test
public void testAtomBasic() throws Exception {
File feedFile = FeedParserTestHelper.getFeedFile("feed-atom-testAtomBasic.xml");
Feed feed = FeedParserTestHelper.runFeedParser(feedFile);
assertEquals(Feed.TYPE_ATOM1, feed.getType());
assertEquals("title", feed.getTitle());
assertEquals("http://example.com/feed", feed.getFeedIdentifier());
assertEquals("http://example.com", feed.getLink());
assertEquals("This is the description", feed.getDescription());
assertEquals("http://example.com/payment", feed.getPaymentLinks().get(0).url);
assertEquals("http://example.com/picture", feed.getImageUrl());
assertEquals(10, feed.getItems().size());
for (int i = 0; i < feed.getItems().size(); i++) {
FeedItem item = feed.getItems().get(i);
assertEquals("http://example.com/item-" + i, item.getItemIdentifier());
assertEquals("item-" + i, item.getTitle());
assertNull(item.getDescription());
assertEquals("http://example.com/items/" + i, item.getLink());
assertEquals(new Date(i * 60000), item.getPubDate());
assertNull(item.getPaymentLink());
assertEquals("http://example.com/picture", item.getImageLocation());
// media
assertTrue(item.hasMedia());
FeedMedia media = item.getMedia();
// noinspection ConstantConditions
assertEquals("http://example.com/media-" + i, media.getDownload_url());
assertEquals(1024 * 1024, media.getSize());
assertEquals("audio/mp3", media.getMime_type());
// chapters
assertNull(item.getChapters());
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class Atom method handleElementEnd.
@Override
public void handleElementEnd(String localName, HandlerState state) {
if (ENTRY.equals(localName)) {
if (state.getCurrentItem() != null && state.getTempObjects().containsKey(Itunes.DURATION)) {
FeedItem currentItem = state.getCurrentItem();
if (currentItem.hasMedia()) {
Integer duration = (Integer) state.getTempObjects().get(Itunes.DURATION);
currentItem.getMedia().setDuration(duration);
}
state.getTempObjects().remove(Itunes.DURATION);
}
state.setCurrentItem(null);
}
if (state.getTagstack().size() >= 2) {
AtomText textElement = null;
String contentRaw;
if (state.getContentBuf() != null) {
contentRaw = state.getContentBuf().toString();
} else {
contentRaw = "";
}
String content = SyndStringUtils.trimAllWhitespace(contentRaw);
SyndElement topElement = state.getTagstack().peek();
String top = topElement.getName();
SyndElement secondElement = state.getSecondTag();
String second = secondElement.getName();
if (top.matches(isText)) {
textElement = (AtomText) topElement;
textElement.setContent(content);
}
if (ID.equals(top)) {
if (FEED.equals(second) && state.getFeed() != null) {
state.getFeed().setFeedIdentifier(contentRaw);
} else if (ENTRY.equals(second) && state.getCurrentItem() != null) {
state.getCurrentItem().setItemIdentifier(contentRaw);
}
} else if (TITLE.equals(top) && textElement != null) {
if (FEED.equals(second) && state.getFeed() != null) {
state.getFeed().setTitle(textElement.getProcessedContent());
} else if (ENTRY.equals(second) && state.getCurrentItem() != null) {
state.getCurrentItem().setTitle(textElement.getProcessedContent());
}
} else if (SUBTITLE.equals(top) && FEED.equals(second) && textElement != null && state.getFeed() != null) {
state.getFeed().setDescription(textElement.getProcessedContent());
} else if (CONTENT.equals(top) && ENTRY.equals(second) && textElement != null && state.getCurrentItem() != null) {
state.getCurrentItem().setDescriptionIfLonger(textElement.getProcessedContent());
} else if (SUMMARY.equals(top) && ENTRY.equals(second) && textElement != null && state.getCurrentItem() != null) {
state.getCurrentItem().setDescriptionIfLonger(textElement.getProcessedContent());
} else if (UPDATED.equals(top) && ENTRY.equals(second) && state.getCurrentItem() != null && state.getCurrentItem().getPubDate() == null) {
state.getCurrentItem().setPubDate(DateUtils.parseOrNullIfFuture(content));
} else if (PUBLISHED.equals(top) && ENTRY.equals(second) && state.getCurrentItem() != null) {
state.getCurrentItem().setPubDate(DateUtils.parseOrNullIfFuture(content));
} else if (IMAGE_LOGO.equals(top) && state.getFeed() != null && state.getFeed().getImageUrl() == null) {
state.getFeed().setImageUrl(content);
} else if (IMAGE_ICON.equals(top) && state.getFeed() != null) {
state.getFeed().setImageUrl(content);
} else if (AUTHOR_NAME.equals(top) && AUTHOR.equals(second) && state.getFeed() != null && state.getCurrentItem() == null) {
String currentName = state.getFeed().getAuthor();
if (currentName == null) {
state.getFeed().setAuthor(content);
} else {
state.getFeed().setAuthor(currentName + ", " + content);
}
}
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class PlaybackSpeedUtils method getCurrentPlaybackSpeed.
/**
* Returns the currently configured playback speed for the specified media.
*/
public static float getCurrentPlaybackSpeed(Playable media) {
float playbackSpeed = SPEED_USE_GLOBAL;
MediaType mediaType = null;
if (media != null) {
mediaType = media.getMediaType();
playbackSpeed = PlaybackPreferences.getCurrentlyPlayingTemporaryPlaybackSpeed();
if (playbackSpeed == SPEED_USE_GLOBAL && media instanceof FeedMedia) {
FeedItem item = ((FeedMedia) media).getItem();
if (item != null) {
Feed feed = item.getFeed();
if (feed != null && feed.getPreferences() != null) {
playbackSpeed = feed.getPreferences().getFeedPlaybackSpeed();
} else {
Log.d(TAG, "Can not get feed specific playback speed: " + feed);
}
}
}
}
if (playbackSpeed == SPEED_USE_GLOBAL) {
playbackSpeed = UserPreferences.getPlaybackSpeed(mediaType);
}
return playbackSpeed;
}
Aggregations