From 19fb75addfcfcd58453149120c6dd61d1c86b534 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 17 Jan 2016 14:18:18 +0100 Subject: [PATCH 1/2] Refactor --- .../core/syndication/namespace/atom/NSAtom.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java index a690e7646..7355a733b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java @@ -4,7 +4,6 @@ import android.util.Log; import org.xml.sax.Attributes; -import de.danoeh.antennapod.core.BuildConfig; import de.danoeh.antennapod.core.feed.FeedImage; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; @@ -88,16 +87,15 @@ public class NSAtom extends Namespace { size = Long.parseLong(strSize); } } catch (NumberFormatException e) { - if (BuildConfig.DEBUG) Log.d(TAG, "Length attribute could not be parsed."); + Log.d(TAG, "Length attribute could not be parsed."); } String type = attributes.getValue(LINK_TYPE); if (SyndTypeUtils.enclosureTypeValid(type) - || (type = SyndTypeUtils - .getValidMimeTypeFromUrl(href)) != null) { state.getCurrentItem().setMedia( new FeedMedia(state.getCurrentItem(), href, size, type) ); + || (type = SyndTypeUtils.getValidMimeTypeFromUrl(href)) != null) { } } else if (rel.equals(LINK_REL_PAYMENT)) { state.getCurrentItem().setPaymentLink(href); @@ -111,9 +109,11 @@ public class NSAtom extends Namespace { * LINK_TYPE_HTML or LINK_TYPE_XHTML */ if ((type == null && state.getFeed().getLink() == null) - || (type != null && (type.equals(LINK_TYPE_HTML) || type.equals(LINK_TYPE_XHTML)))) { + || (type != null && (type.equals(LINK_TYPE_HTML) + || type.equals(LINK_TYPE_XHTML)))) { state.getFeed().setLink(href); - } else if (type != null && (type.equals(LINK_TYPE_ATOM) || type.equals(LINK_TYPE_RSS))) { + } else if (type != null && (type.equals(LINK_TYPE_ATOM) + || type.equals(LINK_TYPE_RSS))) { // treat as podlove alternate feed String title = attributes.getValue(LINK_TITLE); if (title == null) { From 2662f5828f0e0bd44f154210f276beec4177bf8b Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 17 Jan 2016 14:19:08 +0100 Subject: [PATCH 2/2] If atom feed item has multiple enclosures, use first one --- .../core/syndication/namespace/atom/NSAtom.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java index 7355a733b..b23a142af 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java @@ -91,11 +91,11 @@ public class NSAtom extends Namespace { } String type = attributes.getValue(LINK_TYPE); if (SyndTypeUtils.enclosureTypeValid(type) - state.getCurrentItem().setMedia( - new FeedMedia(state.getCurrentItem(), href, - size, type) - ); || (type = SyndTypeUtils.getValidMimeTypeFromUrl(href)) != null) { + FeedItem currItem = state.getCurrentItem(); + if(!currItem.hasMedia()) { + currItem.setMedia(new FeedMedia(currItem, href, size, type)); + } } } else if (rel.equals(LINK_REL_PAYMENT)) { state.getCurrentItem().setPaymentLink(href);