Added some more getters and setters for feed classes
This commit is contained in:
parent
1a9c6053df
commit
d63097d696
|
@ -17,3 +17,7 @@ local.properties
|
||||||
|
|
||||||
# Backup files
|
# Backup files
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
# Eclipse project files
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
package de.podfetcher.feed;
|
package de.podfetcher.feed;
|
||||||
|
|
||||||
public class FeedCategory extends FeedComponent{
|
public class FeedCategory extends FeedComponent{
|
||||||
public String name;
|
protected String name;
|
||||||
|
|
||||||
public FeedCategory(String name) {
|
public FeedCategory(String name) {
|
||||||
super();
|
super();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.podfetcher.feed;
|
package de.podfetcher.feed;
|
||||||
|
|
||||||
public class FeedImage extends FeedFile {
|
public class FeedImage extends FeedFile {
|
||||||
public String title;
|
protected String title;
|
||||||
|
|
||||||
public FeedImage(String download_url, String title) {
|
public FeedImage(String download_url, String title) {
|
||||||
super();
|
super();
|
||||||
|
@ -19,6 +19,12 @@ public class FeedImage extends FeedFile {
|
||||||
public FeedImage() {
|
public FeedImage() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@ package de.podfetcher.feed;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FeedItem extends FeedComponent{
|
public class FeedItem extends FeedComponent{
|
||||||
public String title;
|
private String title;
|
||||||
public String description;
|
private String description;
|
||||||
public String link;
|
private String link;
|
||||||
public String pubDate;
|
private String pubDate;
|
||||||
public FeedMedia media;
|
private FeedMedia media;
|
||||||
public Feed feed;
|
private Feed feed;
|
||||||
public boolean read;
|
private boolean read;
|
||||||
|
|
||||||
public FeedItem() {
|
public FeedItem() {
|
||||||
this.read = false;
|
this.read = false;
|
||||||
|
@ -30,4 +30,62 @@ public class FeedItem extends FeedComponent{
|
||||||
this.feed = feed;
|
this.feed = feed;
|
||||||
this.read = false;
|
this.read = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPubDate() {
|
||||||
|
return pubDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPubDate(String pubDate) {
|
||||||
|
this.pubDate = pubDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeedMedia getMedia() {
|
||||||
|
return media;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMedia(FeedMedia media) {
|
||||||
|
this.media = media;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Feed getFeed() {
|
||||||
|
return feed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeed(Feed feed) {
|
||||||
|
this.feed = feed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRead() {
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRead(boolean read) {
|
||||||
|
this.read = read;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,13 +60,13 @@ public class FeedManager {
|
||||||
public void addFeedItem(Context context, FeedItem item) {
|
public void addFeedItem(Context context, FeedItem item) {
|
||||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||||
// Search list for feeditem
|
// Search list for feeditem
|
||||||
Feed foundFeed = searchFeedByLink(item.link);
|
Feed foundFeed = searchFeedByLink(item.getLink());
|
||||||
FeedItem foundItem = searchFeedItemByLink(foundFeed, item.link);
|
FeedItem foundItem = searchFeedItemByLink(foundFeed, item.getLink());
|
||||||
if(foundItem != null) {
|
if(foundItem != null) {
|
||||||
// Update Information
|
// Update Information
|
||||||
item.id = foundItem.id;
|
item.id = foundItem.id;
|
||||||
foundItem = item;
|
foundItem = item;
|
||||||
item.read = foundItem.read;
|
item.setRead(foundItem.isRead());
|
||||||
adapter.setFeedItem(item);
|
adapter.setFeedItem(item);
|
||||||
} else {
|
} else {
|
||||||
foundFeed.getItems().add(item);
|
foundFeed.getItems().add(item);
|
||||||
|
@ -87,7 +87,7 @@ public class FeedManager {
|
||||||
/** Get a FeedItem by its link */
|
/** Get a FeedItem by its link */
|
||||||
private FeedItem searchFeedItemByLink(Feed feed, String link) {
|
private FeedItem searchFeedItemByLink(Feed feed, String link) {
|
||||||
for(FeedItem item : feed.getItems()) {
|
for(FeedItem item : feed.getItems()) {
|
||||||
if(item.link.equals(link)) {
|
if(item.getLink().equals(link)) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,12 +158,12 @@ public class FeedManager {
|
||||||
FeedItem item = new FeedItem();
|
FeedItem item = new FeedItem();
|
||||||
|
|
||||||
item.id = itemlistCursor.getLong(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_ID));
|
item.id = itemlistCursor.getLong(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_ID));
|
||||||
item.title = itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_TITLE));
|
item.setTitle(itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_TITLE)));
|
||||||
item.link = itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_LINK));
|
item.setLink(itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_LINK)));
|
||||||
item.description = itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION));
|
item.setDescription(itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION)));
|
||||||
item.pubDate = itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_PUBDATE));
|
item.setPubDate(itemlistCursor.getString(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_PUBDATE)));
|
||||||
item.media = adapter.getFeedMedia(itemlistCursor.getLong(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_MEDIA)));
|
item.setMedia(adapter.getFeedMedia(itemlistCursor.getLong(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_MEDIA))));
|
||||||
item.read = (itemlistCursor.getInt(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_READ)) > 0) ? true : false;
|
item.setRead((itemlistCursor.getInt(itemlistCursor.getColumnIndex(PodDBAdapter.KEY_READ)) > 0) ? true : false);
|
||||||
|
|
||||||
items.add(item);
|
items.add(item);
|
||||||
} while(itemlistCursor.moveToNext());
|
} while(itemlistCursor.moveToNext());
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package de.podfetcher.feed;
|
package de.podfetcher.feed;
|
||||||
|
|
||||||
public class FeedMedia extends FeedFile{
|
public class FeedMedia extends FeedFile{
|
||||||
public long length;
|
private long length;
|
||||||
public long position;
|
private long position;
|
||||||
public long size; // File size in Byte
|
private long size; // File size in Byte
|
||||||
public String mime_type;
|
private String mime_type;
|
||||||
|
|
||||||
public FeedItem item; // TODO remove
|
private FeedItem item; // TODO remove
|
||||||
|
|
||||||
public FeedMedia(FeedItem i, String download_url, long size, String mime_type) {
|
public FeedMedia(FeedItem i, String download_url, long size, String mime_type) {
|
||||||
this.item = i;
|
this.item = i;
|
||||||
|
@ -26,6 +26,48 @@ public class FeedMedia extends FeedFile{
|
||||||
this.file_url = file_url;
|
this.file_url = file_url;
|
||||||
this.download_url = download_url;
|
this.download_url = download_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(long length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(long position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(long size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMime_type() {
|
||||||
|
return mime_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMime_type(String mime_type) {
|
||||||
|
this.mime_type = mime_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeedItem getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(FeedItem item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ public class RSSHandler extends DefaultHandler {
|
||||||
public void endElement(String uri, String localName, String qName)
|
public void endElement(String uri, String localName, String qName)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
if (qName.equalsIgnoreCase(FeedHandler.ITEM)) {
|
if (qName.equalsIgnoreCase(FeedHandler.ITEM)) {
|
||||||
currentItem.feed = feed;
|
currentItem.setFeed(feed);
|
||||||
items.add(currentItem);
|
items.add(currentItem);
|
||||||
} else if (qName.equalsIgnoreCase(FeedHandler.TITLE)) {
|
} else if (qName.equalsIgnoreCase(FeedHandler.TITLE)) {
|
||||||
if (active_root_element.equalsIgnoreCase(FeedHandler.CHANNEL)) {
|
if (active_root_element.equalsIgnoreCase(FeedHandler.CHANNEL)) {
|
||||||
feed.setTitle(strBuilder.toString());
|
feed.setTitle(strBuilder.toString());
|
||||||
} else if(active_root_element.equalsIgnoreCase(FeedHandler.TITLE)) {
|
} else if(active_root_element.equalsIgnoreCase(FeedHandler.TITLE)) {
|
||||||
currentItem.title = strBuilder.toString();
|
currentItem.setTitle(strBuilder.toString());
|
||||||
} else if(active_root_element.equalsIgnoreCase(FeedHandler.IMAGE)) {
|
} else if(active_root_element.equalsIgnoreCase(FeedHandler.IMAGE)) {
|
||||||
feed.getImage().title = strBuilder.toString();
|
feed.getImage().title = strBuilder.toString();
|
||||||
}
|
}
|
||||||
|
@ -57,17 +57,17 @@ public class RSSHandler extends DefaultHandler {
|
||||||
if (active_root_element.equalsIgnoreCase(FeedHandler.CHANNEL)) {
|
if (active_root_element.equalsIgnoreCase(FeedHandler.CHANNEL)) {
|
||||||
feed.setDescription(strBuilder.toString());
|
feed.setDescription(strBuilder.toString());
|
||||||
} else {
|
} else {
|
||||||
currentItem.description = strBuilder.toString();
|
currentItem.setDescription(strBuilder.toString());
|
||||||
}
|
}
|
||||||
} else if (qName.equalsIgnoreCase(FeedHandler.LINK)) {
|
} else if (qName.equalsIgnoreCase(FeedHandler.LINK)) {
|
||||||
if (active_root_element.equalsIgnoreCase(FeedHandler.CHANNEL)) {
|
if (active_root_element.equalsIgnoreCase(FeedHandler.CHANNEL)) {
|
||||||
feed.setLink(strBuilder.toString());
|
feed.setLink(strBuilder.toString());
|
||||||
} else if(active_root_element.equalsIgnoreCase(FeedHandler.TITLE)){
|
} else if(active_root_element.equalsIgnoreCase(FeedHandler.TITLE)){
|
||||||
currentItem.link = strBuilder.toString();
|
currentItem.setLink(strBuilder.toString());
|
||||||
}
|
}
|
||||||
} else if (qName.equalsIgnoreCase(FeedHandler.PUBDATE)) {
|
} else if (qName.equalsIgnoreCase(FeedHandler.PUBDATE)) {
|
||||||
if (active_root_element.equalsIgnoreCase(FeedHandler.ITEM)) {
|
if (active_root_element.equalsIgnoreCase(FeedHandler.ITEM)) {
|
||||||
currentItem.pubDate = strBuilder.toString();
|
currentItem.setPubDate(strBuilder.toString());
|
||||||
}
|
}
|
||||||
} else if (qName.equalsIgnoreCase(FeedHandler.URL)) {
|
} else if (qName.equalsIgnoreCase(FeedHandler.URL)) {
|
||||||
if(active_root_element.equalsIgnoreCase(FeedHandler.IMAGE)) {
|
if(active_root_element.equalsIgnoreCase(FeedHandler.IMAGE)) {
|
||||||
|
@ -107,10 +107,10 @@ public class RSSHandler extends DefaultHandler {
|
||||||
} else if (qName.equalsIgnoreCase(FeedHandler.PUBDATE)) {
|
} else if (qName.equalsIgnoreCase(FeedHandler.PUBDATE)) {
|
||||||
active_sub_element = qName;
|
active_sub_element = qName;
|
||||||
} else if (qName.equalsIgnoreCase(FeedHandler.ENCLOSURE)) {
|
} else if (qName.equalsIgnoreCase(FeedHandler.ENCLOSURE)) {
|
||||||
currentItem.media = new FeedMedia(currentItem,
|
currentItem.setMedia(new FeedMedia(currentItem,
|
||||||
attributes.getValue(FeedHandler.ENC_URL),
|
attributes.getValue(FeedHandler.ENC_URL),
|
||||||
Long.parseLong(attributes.getValue(FeedHandler.ENC_LEN)),
|
Long.parseLong(attributes.getValue(FeedHandler.ENC_LEN)),
|
||||||
attributes.getValue(FeedHandler.ENC_TYPE));
|
attributes.getValue(FeedHandler.ENC_TYPE)));
|
||||||
} else if(qName.equalsIgnoreCase(FeedHandler.IMAGE)) {
|
} else if(qName.equalsIgnoreCase(FeedHandler.IMAGE)) {
|
||||||
feed.setImage(new FeedImage());
|
feed.setImage(new FeedImage());
|
||||||
active_root_element = qName;
|
active_root_element = qName;
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class PodDBAdapter {
|
||||||
* */
|
* */
|
||||||
public long setCategory(FeedCategory category) {
|
public long setCategory(FeedCategory category) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(KEY_NAME, category.name);
|
values.put(KEY_NAME, category.getName());
|
||||||
if(category.getId() == 0) {
|
if(category.getId() == 0) {
|
||||||
category.setId(db.insert(TABLE_NAME_FEED_CATEGORIES, null, values));
|
category.setId(db.insert(TABLE_NAME_FEED_CATEGORIES, null, values));
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,7 +159,7 @@ public class PodDBAdapter {
|
||||||
* */
|
* */
|
||||||
public long setImage(FeedImage image) {
|
public long setImage(FeedImage image) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(KEY_TITLE, image.title);
|
values.put(KEY_TITLE, image.getTitle());
|
||||||
values.put(KEY_DOWNLOAD_URL, image.getDownload_url());
|
values.put(KEY_DOWNLOAD_URL, image.getDownload_url());
|
||||||
if(image.getFile_url() != null) {
|
if(image.getFile_url() != null) {
|
||||||
values.put(KEY_FILE_URL, image.getFile_url());
|
values.put(KEY_FILE_URL, image.getFile_url());
|
||||||
|
@ -178,10 +178,10 @@ public class PodDBAdapter {
|
||||||
*/
|
*/
|
||||||
public long setMedia(FeedMedia media) {
|
public long setMedia(FeedMedia media) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(KEY_LENGTH, media.length);
|
values.put(KEY_LENGTH, media.getLength());
|
||||||
values.put(KEY_POSITION, media.position);
|
values.put(KEY_POSITION, media.getPosition());
|
||||||
values.put(KEY_SIZE, media.size);
|
values.put(KEY_SIZE, media.getSize());
|
||||||
values.put(KEY_MIME_TYPE, media.mime_type);
|
values.put(KEY_MIME_TYPE, media.getMime_type());
|
||||||
values.put(KEY_DOWNLOAD_URL, media.getDownload_url());
|
values.put(KEY_DOWNLOAD_URL, media.getDownload_url());
|
||||||
if(media.getFile_url() != null) {
|
if(media.getFile_url() != null) {
|
||||||
values.put(KEY_FILE_URL, media.getFile_url());
|
values.put(KEY_FILE_URL, media.getFile_url());
|
||||||
|
@ -200,21 +200,21 @@ public class PodDBAdapter {
|
||||||
*/
|
*/
|
||||||
public long setFeedItem(FeedItem item) {
|
public long setFeedItem(FeedItem item) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(KEY_TITLE, item.title);
|
values.put(KEY_TITLE, item.getTitle());
|
||||||
values.put(KEY_LINK, item.link);
|
values.put(KEY_LINK, item.getLink());
|
||||||
values.put(KEY_DESCRIPTION, item.description);
|
values.put(KEY_DESCRIPTION, item.getDescription());
|
||||||
values.put(KEY_PUBDATE, item.pubDate);
|
values.put(KEY_PUBDATE, item.getPubDate());
|
||||||
if(item.media != null) {
|
if(item.getMedia() != null) {
|
||||||
if(item.media.getId() == 0) {
|
if(item.getMedia().getId() == 0) {
|
||||||
setMedia(item.media);
|
setMedia(item.getMedia());
|
||||||
}
|
}
|
||||||
values.put(KEY_MEDIA, item.media.getId());
|
values.put(KEY_MEDIA, item.getMedia().getId());
|
||||||
}
|
}
|
||||||
if(item.feed.getId() == 0) {
|
if(item.getFeed().getId() == 0) {
|
||||||
setFeed(item.feed);
|
setFeed(item.getFeed());
|
||||||
}
|
}
|
||||||
values.put(KEY_FEED, item.feed.getId());
|
values.put(KEY_FEED, item.getFeed().getId());
|
||||||
values.put(KEY_READ, (item.read) ? 1 : 0);
|
values.put(KEY_READ, (item.isRead()) ? 1 : 0);
|
||||||
return item.getId();
|
return item.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public class PodDBAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cursor getFeedMediaOfItemCursor(FeedItem item) {
|
public Cursor getFeedMediaOfItemCursor(FeedItem item) {
|
||||||
return db.query(TABLE_NAME_FEED_MEDIA, null, KEY_ID+"=?", new String[]{String.valueOf(item.media.getId())}, null, null, null);
|
return db.query(TABLE_NAME_FEED_MEDIA, null, KEY_ID+"=?", new String[]{String.valueOf(item.getMedia().getId())}, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cursor getImageOfFeedCursor(Feed feed) {
|
public Cursor getImageOfFeedCursor(Feed feed) {
|
||||||
|
|
Loading…
Reference in New Issue