Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added author field to RssItem and removed the RssFeed field #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/nl/matshofman/saxrssreader/RssHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void startElement(String uri, String localName, String qName, Attributes

if(qName.equals("item") && rssFeed != null) {
rssItem = new RssItem();
rssItem.setFeed(rssFeed);
rssFeed.addRssItem(rssItem);
}
}
Expand Down Expand Up @@ -80,8 +79,11 @@ public void endElement(String uri, String localName, String qName) {
// Parse item properties

try {
if(qName.equals("content:encoded"))
if(qName.equals("content:encoded")) {
qName = "content";
} else if(qName.equals("dc:creator")) {
qName = "author";
}
String methodName = "set" + qName.substring(0, 1).toUpperCase() + qName.substring(1);
Method method = rssItem.getClass().getMethod(methodName, String.class);
method.invoke(rssItem, stringBuilder.toString());
Expand Down
22 changes: 11 additions & 11 deletions src/nl/matshofman/saxrssreader/RssItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

public class RssItem implements Comparable<RssItem>, Parcelable {

private RssFeed feed;
private String title;
private String link;
private Date pubDate;
private String description;
private String content;
private String author;

public RssItem() {

Expand All @@ -46,7 +46,7 @@ public RssItem(Parcel source) {
pubDate = (Date) data.getSerializable("pubDate");
description = data.getString("description");
content = data.getString("content");
feed = data.getParcelable("feed");
author = data.getString("author");

}

Expand All @@ -59,7 +59,7 @@ public void writeToParcel(Parcel dest, int flags) {
data.putSerializable("pubDate", pubDate);
data.putString("description", description);
data.putString("content", content);
data.putParcelable("feed", feed);
data.putString("author", author);
dest.writeBundle(data);
}

Expand All @@ -76,14 +76,6 @@ public RssItem[] newArray(int size) {
public int describeContents() {
return 0;
}

public RssFeed getFeed() {
return feed;
}

public void setFeed(RssFeed feed) {
this.feed = feed;
}

public String getTitle() {
return title;
Expand Down Expand Up @@ -134,6 +126,14 @@ public void setContent(String content) {
this.content = content;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

@Override
public int compareTo(RssItem another) {
if(getPubDate() != null && another.getPubDate() != null) {
Expand Down