diff options
Diffstat (limited to 'src/de/danoeh/antennapod/syndication/namespace')
8 files changed, 61 insertions, 56 deletions
diff --git a/src/de/danoeh/antennapod/syndication/namespace/NSContent.java b/src/de/danoeh/antennapod/syndication/namespace/NSContent.java index 7f2a3e87d..9ad3026be 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/NSContent.java +++ b/src/de/danoeh/antennapod/syndication/namespace/NSContent.java @@ -1,8 +1,7 @@ package de.danoeh.antennapod.syndication.namespace; -import org.xml.sax.Attributes; - import de.danoeh.antennapod.syndication.handler.HandlerState; +import org.xml.sax.Attributes; public class NSContent extends Namespace { public static final String NSTAG = "content"; diff --git a/src/de/danoeh/antennapod/syndication/namespace/NSITunes.java b/src/de/danoeh/antennapod/syndication/namespace/NSITunes.java index cd7fef509..d8cbe040b 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/NSITunes.java +++ b/src/de/danoeh/antennapod/syndication/namespace/NSITunes.java @@ -1,40 +1,51 @@ package de.danoeh.antennapod.syndication.namespace; -import org.xml.sax.Attributes; - import de.danoeh.antennapod.feed.FeedImage; import de.danoeh.antennapod.syndication.handler.HandlerState; +import org.xml.sax.Attributes; + +public class NSITunes extends Namespace { + public static final String NSTAG = "itunes"; + public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd"; + + private static final String IMAGE = "image"; + private static final String IMAGE_TITLE = "image"; + private static final String IMAGE_HREF = "href"; + + private static final String AUTHOR = "author"; + + + @Override + public SyndElement handleElementStart(String localName, HandlerState state, + Attributes attributes) { + if (localName.equals(IMAGE)) { + FeedImage image = new FeedImage(); + image.setTitle(IMAGE_TITLE); + image.setDownload_url(attributes.getValue(IMAGE_HREF)); + + if (state.getCurrentItem() != null) { + // this is an items image + image.setTitle(state.getCurrentItem().getTitle() + IMAGE_TITLE); + state.getCurrentItem().setImage(image); + + } else { + // this is the feed image + if (state.getFeed().getImage() == null) { + state.getFeed().setImage(image); + } + } + + } + + return new SyndElement(localName, this); + } + + @Override + public void handleElementEnd(String localName, HandlerState state) { + if (localName.equals(AUTHOR)) { + state.getFeed().setAuthor(state.getContentBuf().toString()); + } -public class NSITunes extends Namespace{ - public static final String NSTAG = "itunes"; - public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd"; - - private static final String IMAGE = "image"; - private static final String IMAGE_TITLE = "image"; - private static final String IMAGE_HREF = "href"; - - private static final String AUTHOR = "author"; - - - @Override - public SyndElement handleElementStart(String localName, HandlerState state, - Attributes attributes) { - if (localName.equals(IMAGE) && state.getFeed().getImage() == null) { - FeedImage image = new FeedImage(); - image.setTitle(IMAGE_TITLE); - image.setDownload_url(attributes.getValue(IMAGE_HREF)); - state.getFeed().setImage(image); - } - - return new SyndElement(localName, this); - } - - @Override - public void handleElementEnd(String localName, HandlerState state) { - if (localName.equals(AUTHOR)) { - state.getFeed().setAuthor(state.getContentBuf().toString()); - } - - } + } } diff --git a/src/de/danoeh/antennapod/syndication/namespace/NSMedia.java b/src/de/danoeh/antennapod/syndication/namespace/NSMedia.java index 053a81270..cc23167c1 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/NSMedia.java +++ b/src/de/danoeh/antennapod/syndication/namespace/NSMedia.java @@ -1,14 +1,13 @@ package de.danoeh.antennapod.syndication.namespace; -import java.util.concurrent.TimeUnit; - -import org.xml.sax.Attributes; - import android.util.Log; -import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.feed.FeedMedia; import de.danoeh.antennapod.syndication.handler.HandlerState; import de.danoeh.antennapod.syndication.util.SyndTypeUtils; +import org.xml.sax.Attributes; + +import java.util.concurrent.TimeUnit; /** Processes tags from the http://search.yahoo.com/mrss/ namespace. */ public class NSMedia extends Namespace { @@ -38,7 +37,7 @@ public class NSMedia extends Namespace { try { size = Long.parseLong(attributes.getValue(SIZE)); } catch (NumberFormatException e) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Length attribute could not be parsed."); } @@ -50,7 +49,7 @@ public class NSMedia extends Namespace { Long.parseLong(durationStr), TimeUnit.SECONDS); } } catch (NumberFormatException e) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Duration attribute could not be parsed"); } diff --git a/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java b/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java index 3eb49172d..9572f87ae 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java +++ b/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java @@ -1,15 +1,14 @@ package de.danoeh.antennapod.syndication.namespace; -import org.xml.sax.Attributes; - import android.util.Log; -import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.feed.FeedImage; import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedMedia; import de.danoeh.antennapod.syndication.handler.HandlerState; import de.danoeh.antennapod.syndication.util.SyndDateUtils; import de.danoeh.antennapod.syndication.util.SyndTypeUtils; +import org.xml.sax.Attributes; /** * SAX-Parser for reading RSS-Feeds @@ -57,7 +56,7 @@ public class NSRSS20 extends Namespace { try { size = Long.parseLong(attributes.getValue(ENC_LEN)); } catch (NumberFormatException e) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Length attribute could not be parsed."); } state.getCurrentItem().setMedia( diff --git a/src/de/danoeh/antennapod/syndication/namespace/NSSimpleChapters.java b/src/de/danoeh/antennapod/syndication/namespace/NSSimpleChapters.java index 55c26e812..3f983ee88 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/NSSimpleChapters.java +++ b/src/de/danoeh/antennapod/syndication/namespace/NSSimpleChapters.java @@ -1,13 +1,12 @@ package de.danoeh.antennapod.syndication.namespace; -import java.util.ArrayList; - -import org.xml.sax.Attributes; - import de.danoeh.antennapod.feed.Chapter; import de.danoeh.antennapod.feed.SimpleChapter; import de.danoeh.antennapod.syndication.handler.HandlerState; import de.danoeh.antennapod.syndication.util.SyndDateUtils; +import org.xml.sax.Attributes; + +import java.util.ArrayList; public class NSSimpleChapters extends Namespace { public static final String NSTAG = "psc|sc"; diff --git a/src/de/danoeh/antennapod/syndication/namespace/Namespace.java b/src/de/danoeh/antennapod/syndication/namespace/Namespace.java index 9eafef71e..910131feb 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/Namespace.java +++ b/src/de/danoeh/antennapod/syndication/namespace/Namespace.java @@ -1,8 +1,7 @@ package de.danoeh.antennapod.syndication.namespace; -import org.xml.sax.Attributes; - import de.danoeh.antennapod.syndication.handler.HandlerState; +import org.xml.sax.Attributes; public abstract class Namespace { diff --git a/src/de/danoeh/antennapod/syndication/namespace/atom/AtomText.java b/src/de/danoeh/antennapod/syndication/namespace/atom/AtomText.java index fec20de2f..86b80d2ed 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/atom/AtomText.java +++ b/src/de/danoeh/antennapod/syndication/namespace/atom/AtomText.java @@ -1,9 +1,8 @@ package de.danoeh.antennapod.syndication.namespace.atom; -import org.apache.commons.lang3.StringEscapeUtils; - import de.danoeh.antennapod.syndication.namespace.Namespace; import de.danoeh.antennapod.syndication.namespace.SyndElement; +import org.apache.commons.lang3.StringEscapeUtils; /** Represents Atom Element which contains text (content, title, summary). */ public class AtomText extends SyndElement { diff --git a/src/de/danoeh/antennapod/syndication/namespace/atom/NSAtom.java b/src/de/danoeh/antennapod/syndication/namespace/atom/NSAtom.java index bc68d6f6a..383b29fc8 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/atom/NSAtom.java +++ b/src/de/danoeh/antennapod/syndication/namespace/atom/NSAtom.java @@ -1,7 +1,7 @@ package de.danoeh.antennapod.syndication.namespace.atom; import android.util.Log; -import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.feed.FeedImage; import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedMedia; @@ -84,7 +84,7 @@ public class NSAtom extends Namespace { size = Long.parseLong(strSize); } } catch (NumberFormatException e) { - if (AppConfig.DEBUG) Log.d(TAG, "Length attribute could not be parsed."); + if (BuildConfig.DEBUG) Log.d(TAG, "Length attribute could not be parsed."); } String type = attributes.getValue(LINK_TYPE); if (SyndTypeUtils.enclosureTypeValid(type) |