From 518cada73fd6d2c00235bf9b3609e33ded87fd8d Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Mon, 11 Feb 2019 18:16:01 +0000 Subject: [PATCH] Fixing RSS content tag parsing, there may be more than one --- .../readrops/app/database/entities/Item.java | 12 ++++++++++-- .../readropslibrary/localfeed/rss/RSSItem.java | 17 ++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/readrops/app/database/entities/Item.java b/app/src/main/java/com/readrops/app/database/entities/Item.java index cbf33c22..5d44a044 100644 --- a/app/src/main/java/com/readrops/app/database/entities/Item.java +++ b/app/src/main/java/com/readrops/app/database/entities/Item.java @@ -6,6 +6,7 @@ import com.readrops.app.utils.DateUtils; import com.readrops.readropslibrary.localfeed.atom.ATOMEntry; import com.readrops.readropslibrary.localfeed.json.JSONItem; import com.readrops.readropslibrary.localfeed.rss.RSSItem; +import com.readrops.readropslibrary.localfeed.rss.RSSMediaContent; import org.joda.time.LocalDateTime; @@ -175,8 +176,15 @@ public class Item { newItem.setLink(item.getLink()); newItem.setFeedId(feed.getId()); - if (item.getMediaContent() != null && item.getMediaContent().isContentAnImage()) - newItem.setImageLink(item.getMediaContent().getUrl()); + if (item.getMediaContents() != null && item.getMediaContents().size() > 0) { + for (RSSMediaContent mediaContent : item.getMediaContents()) { + if (mediaContent.isContentAnImage()) { + newItem.setImageLink(mediaContent.getUrl()); + break; + } + } + + } dbItems.add(newItem); } diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/localfeed/rss/RSSItem.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/localfeed/rss/RSSItem.java index 5e8f808f..46118ca1 100644 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/localfeed/rss/RSSItem.java +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/localfeed/rss/RSSItem.java @@ -3,9 +3,12 @@ package com.readrops.readropslibrary.localfeed.rss; import com.readrops.readropslibrary.localfeed.AItem; import org.simpleframework.xml.Element; +import org.simpleframework.xml.ElementList; import org.simpleframework.xml.Namespace; import org.simpleframework.xml.Root; +import java.util.List; + @Root(name = "item", strict = false) public class RSSItem extends AItem { @@ -21,9 +24,9 @@ public class RSSItem extends AItem { @Element(name = "imageLink", required = false) private String imageLink; - @Element(name = "content", required = false) + @ElementList(name = "content", inline = true, required = false) @Namespace(prefix = "media") - private RSSMediaContent mediaContent; + private List mediaContents; @Element(name = "creator", required = false) @Namespace(prefix = "dc", reference = "http://purl.org/dc/elements/1.1/") @@ -32,7 +35,7 @@ public class RSSItem extends AItem { @Element(name = "pubDate", required = false) private String pubDate; - @Element(name = "encoded",required = false, data = true) + @Element(name = "encoded", required = false) @Namespace(prefix = "content") private String content; @@ -103,11 +106,11 @@ public class RSSItem extends AItem { this.guid = guid; } - public RSSMediaContent getMediaContent() { - return mediaContent; + public List getMediaContents() { + return mediaContents; } - public void setMediaContent(RSSMediaContent mediaContent) { - this.mediaContent = mediaContent; + public void setMediaContents(List mediaContents) { + this.mediaContents = mediaContents; } }