Add media:content tag parsing for the RSS format and displaying it when it's an image

This commit is contained in:
Shinokuni 2019-02-03 21:40:51 +00:00
parent 3d1919c49c
commit 808d442735
7 changed files with 51 additions and 55 deletions

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipartAsset">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/Applications/Android%20Studio.app/Contents/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_add_black_24dp.xml" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="color" value="ffffff" />
<entry key="outputName" value="ic_add_white" />
<entry key="sourceFile" value="$USER_HOME$" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="UNCHECKED_WARNING" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

View File

@ -182,7 +182,9 @@ public class LocalFeedRepository extends ARepository implements QueryCallback {
for (Item dbItem : items) {
if (!Boolean.valueOf(database.itemDao().guidExist(dbItem.getGuid()))) {
if (dbItem.getDescription() != null) {
dbItem.setImageLink(HtmlParser.getDescImageLink(dbItem.getDescription()));
if (dbItem.getImageLink() == null)
dbItem.setImageLink(HtmlParser.getDescImageLink(dbItem.getDescription()));
dbItem.setDescription(Jsoup.parse(dbItem.getDescription()).text());
}

View File

@ -139,13 +139,16 @@ public class Item {
newItem.setDescription(item.getDescription());
newItem.setGuid(item.getGuid());
newItem.setTitle(item.getTitle());
newItem.setImageLink(item.getImageLink());
newItem.setPubDate(DateUtils.stringToDateTime(item.getPubDate(), DateUtils.RSS_DATE_FORMAT));
newItem.setLink(item.getLink());
newItem.setFeedId(feed.getId());
if (item.getMediaContent() != null && item.getMediaContent().isContentAnImage())
newItem.setImageLink(item.getMediaContent().getUrl());
dbItems.add(newItem);
}

View File

@ -21,6 +21,10 @@ public class RSSItem extends AItem {
@Element(name = "imageLink", required = false)
private String imageLink;
@Element(name = "content", required = false)
@Namespace(prefix = "media")
private RSSMediaContent mediaContent;
@Element(name = "author", required = false)
private String author;
@ -98,5 +102,11 @@ public class RSSItem extends AItem {
this.guid = guid;
}
public RSSMediaContent getMediaContent() {
return mediaContent;
}
public void setMediaContent(RSSMediaContent mediaContent) {
this.mediaContent = mediaContent;
}
}

View File

@ -0,0 +1,34 @@
package com.readrops.readropslibrary.localfeed.rss;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Root(name = "content", strict = false)
public class RSSMediaContent {
@Attribute(required = false)
private String url;
@Attribute(required = false)
private String medium;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMedium() {
return medium;
}
public void setMedium(String medium) {
this.medium = medium;
}
public boolean isContentAnImage() {
return medium.equals("image");
}
}