Search in sources :

Example 56 with Feed

use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.

the class HtmlWriter method writeDocument.

/**
     * Takes a list of feeds and a writer and writes those into an HTML
     * document.
     *
     * @throws IOException
     * @throws IllegalStateException
     * @throws IllegalArgumentException
     */
@Override
public void writeDocument(List<Feed> feeds, Writer writer) throws IllegalArgumentException, IllegalStateException, IOException {
    Log.d(TAG, "Starting to write document");
    XmlSerializer xs = Xml.newSerializer();
    xs.setFeature(HtmlSymbols.XML_FEATURE_INDENT_OUTPUT, true);
    xs.setOutput(writer);
    xs.startDocument(ENCODING, false);
    xs.startTag(null, HtmlSymbols.HTML);
    xs.startTag(null, HtmlSymbols.HEAD);
    xs.startTag(null, HtmlSymbols.TITLE);
    xs.text(HTML_TITLE);
    xs.endTag(null, HtmlSymbols.TITLE);
    xs.endTag(null, HtmlSymbols.HEAD);
    xs.startTag(null, HtmlSymbols.BODY);
    xs.startTag(null, HtmlSymbols.HEADING);
    xs.text(HTML_TITLE);
    xs.endTag(null, HtmlSymbols.HEADING);
    xs.startTag(null, HtmlSymbols.ORDERED_LIST);
    for (Feed feed : feeds) {
        xs.startTag(null, HtmlSymbols.LIST_ITEM);
        xs.text(feed.getTitle());
        if (!TextUtils.isEmpty(feed.getLink())) {
            xs.text(" [");
            xs.startTag(null, HtmlSymbols.LINK);
            xs.attribute(null, HtmlSymbols.LINK_DESTINATION, feed.getLink());
            xs.text("Website");
            xs.endTag(null, HtmlSymbols.LINK);
            xs.text("]");
        }
        xs.text(" [");
        xs.startTag(null, HtmlSymbols.LINK);
        xs.attribute(null, HtmlSymbols.LINK_DESTINATION, feed.getDownload_url());
        xs.text("Feed");
        xs.endTag(null, HtmlSymbols.LINK);
        xs.text("]");
        xs.endTag(null, HtmlSymbols.LIST_ITEM);
    }
    xs.endTag(null, HtmlSymbols.ORDERED_LIST);
    xs.endTag(null, HtmlSymbols.BODY);
    xs.endTag(null, HtmlSymbols.HTML);
    xs.endDocument();
    Log.d(TAG, "Finished writing document");
}
Also used : XmlSerializer(org.xmlpull.v1.XmlSerializer) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 57 with Feed

use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.

the class DBReader method getFeed.

/**
     * Loads a specific Feed from the database.
     *
     * @param feedId  The ID of the Feed
     * @return The Feed or null if the Feed could not be found. The Feeds FeedItems will also be loaded from the
     * database and the items-attribute will be set correctly.
     */
public static Feed getFeed(final long feedId) {
    Log.d(TAG, "getFeed() called with: " + "feedId = [" + feedId + "]");
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    Feed result = getFeed(feedId, adapter);
    adapter.close();
    return result;
}
Also used : Feed(de.danoeh.antennapod.core.feed.Feed)

Example 58 with Feed

use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.

the class FeedHandlerTest method createTestFeed.

private Feed createTestFeed(int numItems, boolean withImage, boolean withFeedMedia, boolean withChapters) {
    FeedImage image = null;
    if (withImage) {
        image = new FeedImage(0, "image", null, "http://example.com/picture", false);
    }
    Feed feed = new Feed(0, null, "title", "http://example.com", "This is the description", "http://example.com/payment", "Daniel", "en", null, "http://example.com/feed", image, file.getAbsolutePath(), "http://example.com/feed", true);
    feed.setItems(new ArrayList<FeedItem>());
    for (int i = 0; i < numItems; i++) {
        FeedItem item = new FeedItem(0, "item-" + i, "http://example.com/item-" + i, "http://example.com/items/" + i, new Date(i * 60000), FeedItem.UNPLAYED, feed);
        feed.getItems().add(item);
        if (withFeedMedia) {
            item.setMedia(new FeedMedia(0, item, 4711, 0, 1024 * 1024, "audio/mp3", null, "http://example.com/media-" + i, false, null, 0, 0));
        }
    }
    return feed;
}
Also used : FeedImage(de.danoeh.antennapod.core.feed.FeedImage) FeedItem(de.danoeh.antennapod.core.feed.FeedItem) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) Date(java.util.Date) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 59 with Feed

use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.

the class FeedHandlerTest method testRSS2Basic.

public void testRSS2Basic() throws IOException, UnsupportedFeedtypeException, SAXException, ParserConfigurationException {
    Feed f1 = createTestFeed(10, false, true, true);
    Feed f2 = runFeedTest(f1, new RSS2Generator(), "UTF-8", RSS2Generator.FEATURE_WRITE_GUID);
    feedValid(f1, f2, Feed.TYPE_RSS2);
}
Also used : RSS2Generator(de.test.antennapod.util.syndication.feedgenerator.RSS2Generator) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 60 with Feed

use of de.danoeh.antennapod.core.feed.Feed in project AntennaPod by AntennaPod.

the class CastUtils method matches.

/**
     * Compares a {@link MediaInfo} instance with a {@link FeedMedia} one and evaluates whether they
     * represent the same podcast episode.
     *
     * @param info      the {@link MediaInfo} object to be compared.
     * @param media     the {@link FeedMedia} object to be compared.
     * @return <true>true</true> if there's a match, <code>false</code> otherwise.
     *
     * @see RemoteMedia#equals(Object)
     */
public static boolean matches(MediaInfo info, FeedMedia media) {
    if (info == null || media == null) {
        return false;
    }
    if (!TextUtils.equals(info.getContentId(), media.getStreamUrl())) {
        return false;
    }
    MediaMetadata metadata = info.getMetadata();
    FeedItem fi = media.getItem();
    if (fi == null || metadata == null || !TextUtils.equals(metadata.getString(KEY_EPISODE_IDENTIFIER), fi.getItemIdentifier())) {
        return false;
    }
    Feed feed = fi.getFeed();
    return feed != null && TextUtils.equals(metadata.getString(KEY_FEED_URL), feed.getDownload_url());
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) MediaMetadata(com.google.android.gms.cast.MediaMetadata) Feed(de.danoeh.antennapod.core.feed.Feed)

Aggregations

Feed (de.danoeh.antennapod.core.feed.Feed)95 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)55 PodDBAdapter (de.danoeh.antennapod.core.storage.PodDBAdapter)32 ArrayList (java.util.ArrayList)30 Date (java.util.Date)30 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)21 File (java.io.File)20 Cursor (android.database.Cursor)16 FeedImage (de.danoeh.antennapod.core.feed.FeedImage)14 Context (android.content.Context)13 FlakyTest (android.test.FlakyTest)9 DialogInterface (android.content.DialogInterface)8 Intent (android.content.Intent)8 LayoutInflater (android.view.LayoutInflater)7 AdapterView (android.widget.AdapterView)7 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)6 FeedPreferences (de.danoeh.antennapod.core.feed.FeedPreferences)6 DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)6 Log (android.util.Log)4 View (android.view.View)4