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 982f1f86..1d697d51 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
@@ -181,12 +181,14 @@ public class Item {
} catch (ParseException e) {
e.printStackTrace();
} finally {
- try {
- newItem.setPubDate(DateUtils.stringToDateTime(item.getDate(), DateUtils.RSS_2_DATE_FORMAT));
- } catch (ParseException e) {
- e.printStackTrace();
- } finally {
- newItem.setPubDate(DateUtils.stringToDateTime(item.getDate(), DateUtils.ATOM_JSON_DATE_FORMAT));
+ if (newItem.getPubDate() == null) {
+ try {
+ newItem.setPubDate(DateUtils.stringToDateTime(item.getDate(), DateUtils.RSS_2_DATE_FORMAT));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } finally {
+ newItem.setPubDate(DateUtils.stringToDateTime(item.getDate(), DateUtils.ATOM_JSON_DATE_FORMAT));
+ }
}
}
}
@@ -196,7 +198,7 @@ public class Item {
if (item.getMediaContents() != null && item.getMediaContents().size() > 0) {
for (RSSMediaContent mediaContent : item.getMediaContents()) {
- if (Utils.isTypeImage(mediaContent.getMedium())) {
+ if (mediaContent.getMedium() != null && Utils.isTypeImage(mediaContent.getMedium())) {
newItem.setImageLink(mediaContent.getUrl());
break;
}
@@ -204,7 +206,7 @@ public class Item {
} else {
if (item.getEnclosures() != null) {
for (RSSEnclosure enclosure : item.getEnclosures()) {
- if (Utils.isTypeImage(enclosure.getType())) {
+ if (enclosure.getType() != null && Utils.isTypeImage(enclosure.getType())) {
newItem.setImageLink(enclosure.getUrl());
break;
}
diff --git a/app/src/test/java/com/readrops/app/ExampleUnitTest.java b/app/src/test/java/com/readrops/app/ExampleUnitTest.java
index 2aab2b76..b84a46de 100644
--- a/app/src/test/java/com/readrops/app/ExampleUnitTest.java
+++ b/app/src/test/java/com/readrops/app/ExampleUnitTest.java
@@ -15,26 +15,26 @@ import static org.junit.Assert.*;
* @see Testing documentation
*/
public class ExampleUnitTest {
+
@Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
+ public void rssDateTest() {
+ try {
+ LocalDateTime dateTime = new LocalDateTime(2019, 1, 4, 22, 21, 46);
+
+ assertEquals(0, dateTime.compareTo(DateUtils.stringToDateTime("Fri, 04 Jan 2019 22:21:46 +0000", DateUtils.RSS_2_DATE_FORMAT)));
+ assertEquals(0, dateTime.compareTo(DateUtils.stringToDateTime("Fri, 04 Jan 2019 22:21:46 GMT", DateUtils.RSS_2_DATE_FORMAT_2)));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
}
@Test
- public void stringToDateTest() {
- LocalDateTime dateTime = new LocalDateTime(2019, 1, 4, 22, 21, 46);
-
+ public void atomJsonDateTest() {
try {
- // RSS
- assertTrue(dateTime.compareTo(DateUtils.stringToDateTime("Fri, 04 Jan 2019 22:21:46 +0000", DateUtils.RSS_2_DATE_FORMAT)) == 0);
-
- // ATOM
- assertTrue(dateTime.compareTo(DateUtils.stringToDateTime("2019-01-04T22:21:46+00:00", DateUtils.ATOM_JSON_DATE_FORMAT)) == 0);
-
- // JSON
- assertTrue(dateTime.compareTo(DateUtils.stringToDateTime("2019-01-04T22:21:46-0000", DateUtils.ATOM_JSON_DATE_FORMAT)) == 0);
-
+ LocalDateTime dateTime = new LocalDateTime(2019, 1, 4, 22, 21, 46);
+ assertEquals(0, dateTime.compareTo(DateUtils.stringToDateTime("2019-01-04T22:21:46+00:00", DateUtils.ATOM_JSON_DATE_FORMAT)));
+ assertEquals(0, dateTime.compareTo(DateUtils.stringToDateTime("2019-01-04T22:21:46-0000", DateUtils.ATOM_JSON_DATE_FORMAT)));
} catch (ParseException e) {
e.printStackTrace();
}
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 1b6ee77c..736b9f9f 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
@@ -15,12 +15,13 @@ public class RSSItem extends AItem {
@Element(name = "title", required = false)
private String title;
- @Element(name = "description", required = false, data = true)
- private String description;
-
@Element(name = "link", required = false)
private String link;
+ @ElementList(name = "link", inline = true, required = false)
+ @Namespace(prefix = "atom")
+ private List otherLinks;
+
@Element(name = "imageLink", required = false)
private String imageLink;
@@ -33,11 +34,21 @@ public class RSSItem extends AItem {
@Element(name = "creator", required = false)
@Namespace(prefix = "dc", reference = "http://purl.org/dc/elements/1.1/")
+ private String creator;
+
+ @Element(required = false)
private String author;
@Element(name = "pubDate", required = false)
private String pubDate;
+ @Element(name = "date", required = false)
+ @Namespace(prefix = "dc")
+ private String date;
+
+ @Element(name = "description", required = false)
+ private String description;
+
@Element(name = "encoded", required = false)
@Namespace(prefix = "content")
private String content;
@@ -77,12 +88,12 @@ public class RSSItem extends AItem {
this.imageLink = imageLink;
}
- public String getAuthor() {
- return author;
+ public String getCreator() {
+ return creator;
}
- public void setAuthor(String author) {
- this.author = author;
+ public void setCreator(String creator) {
+ this.creator = creator;
}
public String getPubDate() {
@@ -124,4 +135,34 @@ public class RSSItem extends AItem {
public void setEnclosures(List enclosures) {
this.enclosures = enclosures;
}
+
+ public String getDate() {
+ if (pubDate != null)
+ return pubDate;
+ else
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public String getAuthor() {
+ if (creator != null)
+ return creator;
+ else
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public List getOtherLinks() {
+ return otherLinks;
+ }
+
+ public void setOtherLinks(List otherLinks) {
+ this.otherLinks = otherLinks;
+ }
}