Changed type of pubDate in FeedItem to Date
This commit is contained in:
parent
85a1dd7006
commit
db238af642
|
@ -101,7 +101,7 @@ public class ItemviewActivity extends SherlockActivity {
|
||||||
|
|
||||||
setTitle(item.getFeed().getTitle());
|
setTitle(item.getFeed().getTitle());
|
||||||
|
|
||||||
txtvPublished.setText(item.getPubDate());
|
//txtvPublished.setText(item.getPubDate()); TODO fix
|
||||||
txtvTitle.setText(item.getTitle());
|
txtvTitle.setText(item.getTitle());
|
||||||
if(item.getFeed().getImage() != null) {
|
if(item.getFeed().getImage() != null) {
|
||||||
imgvImage.setImageBitmap(item.getFeed().getImage().getImageBitmap());
|
imgvImage.setImageBitmap(item.getFeed().getImage().getImageBitmap());
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package de.podfetcher.feed;
|
package de.podfetcher.feed;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data Object for a XML message
|
* Data Object for a XML message
|
||||||
|
@ -10,7 +12,7 @@ public class FeedItem extends FeedComponent{
|
||||||
private String title;
|
private String title;
|
||||||
private String description;
|
private String description;
|
||||||
private String link;
|
private String link;
|
||||||
private String pubDate;
|
private Date pubDate;
|
||||||
private FeedMedia media;
|
private FeedMedia media;
|
||||||
private Feed feed;
|
private Feed feed;
|
||||||
private boolean read;
|
private boolean read;
|
||||||
|
@ -20,7 +22,7 @@ public class FeedItem extends FeedComponent{
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeedItem(String title, String description, String link,
|
public FeedItem(String title, String description, String link,
|
||||||
String pubDate, FeedMedia media, Feed feed) {
|
Date pubDate, FeedMedia media, Feed feed) {
|
||||||
super();
|
super();
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -55,11 +57,11 @@ public class FeedItem extends FeedComponent{
|
||||||
this.link = link;
|
this.link = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPubDate() {
|
public Date getPubDate() {
|
||||||
return pubDate;
|
return pubDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPubDate(String pubDate) {
|
public void setPubDate(Date pubDate) {
|
||||||
this.pubDate = pubDate;
|
this.pubDate = pubDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.podfetcher.feed;
|
package de.podfetcher.feed;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import de.podfetcher.storage.*;
|
import de.podfetcher.storage.*;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -251,8 +252,8 @@ public class FeedManager {
|
||||||
.getColumnIndex(PodDBAdapter.KEY_LINK)));
|
.getColumnIndex(PodDBAdapter.KEY_LINK)));
|
||||||
item.setDescription(itemlistCursor.getString(itemlistCursor
|
item.setDescription(itemlistCursor.getString(itemlistCursor
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION)));
|
.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION)));
|
||||||
item.setPubDate(itemlistCursor.getString(itemlistCursor
|
item.setPubDate(new Date(itemlistCursor.getLong(itemlistCursor
|
||||||
.getColumnIndex(PodDBAdapter.KEY_PUBDATE)));
|
.getColumnIndex(PodDBAdapter.KEY_PUBDATE))));
|
||||||
item.setMedia(adapter.getFeedMedia(itemlistCursor
|
item.setMedia(adapter.getFeedMedia(itemlistCursor
|
||||||
.getLong(itemlistCursor
|
.getLong(itemlistCursor
|
||||||
.getColumnIndex(PodDBAdapter.KEY_MEDIA)), item));
|
.getColumnIndex(PodDBAdapter.KEY_MEDIA)), item));
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class PodDBAdapter {
|
||||||
private static final String CREATE_TABLE_FEED_ITEMS = "CREATE TABLE "
|
private static final String CREATE_TABLE_FEED_ITEMS = "CREATE TABLE "
|
||||||
+ TABLE_NAME_FEED_ITEMS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
|
+ TABLE_NAME_FEED_ITEMS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
|
||||||
+ " TEXT," + KEY_LINK + " TEXT," + KEY_DESCRIPTION
|
+ " TEXT," + KEY_LINK + " TEXT," + KEY_DESCRIPTION
|
||||||
+ " TEXT," + KEY_PUBDATE + " TEXT," + KEY_MEDIA
|
+ " TEXT," + KEY_PUBDATE + " INTEGER," + KEY_MEDIA
|
||||||
+ " INTEGER," + KEY_FEED + " INTEGER," + KEY_READ
|
+ " INTEGER," + KEY_FEED + " INTEGER," + KEY_READ
|
||||||
+ " INTEGER)";
|
+ " INTEGER)";
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class PodDBAdapter {
|
||||||
values.put(KEY_TITLE, item.getTitle());
|
values.put(KEY_TITLE, item.getTitle());
|
||||||
values.put(KEY_LINK, item.getLink());
|
values.put(KEY_LINK, item.getLink());
|
||||||
values.put(KEY_DESCRIPTION, item.getDescription());
|
values.put(KEY_DESCRIPTION, item.getDescription());
|
||||||
values.put(KEY_PUBDATE, item.getPubDate());
|
values.put(KEY_PUBDATE, item.getPubDate().getTime());
|
||||||
if (item.getMedia() != null) {
|
if (item.getMedia() != null) {
|
||||||
if(item.getMedia().getId() == 0) {
|
if(item.getMedia().getId() == 0) {
|
||||||
setMedia(item.getMedia());
|
setMedia(item.getMedia());
|
||||||
|
|
|
@ -9,6 +9,7 @@ import de.podfetcher.feed.FeedMedia;
|
||||||
import de.podfetcher.syndication.handler.HandlerState;
|
import de.podfetcher.syndication.handler.HandlerState;
|
||||||
import de.podfetcher.syndication.namespace.Namespace;
|
import de.podfetcher.syndication.namespace.Namespace;
|
||||||
import de.podfetcher.syndication.namespace.SyndElement;
|
import de.podfetcher.syndication.namespace.SyndElement;
|
||||||
|
import de.podfetcher.syndication.util.SyndDateUtils;
|
||||||
|
|
||||||
public class NSAtom extends Namespace {
|
public class NSAtom extends Namespace {
|
||||||
public static final String NSTAG = "atom";
|
public static final String NSTAG = "atom";
|
||||||
|
@ -109,7 +110,7 @@ public class NSAtom extends Namespace {
|
||||||
}
|
}
|
||||||
} else if (top.equals(PUBLISHED)) {
|
} else if (top.equals(PUBLISHED)) {
|
||||||
if (second.equals(ENTRY)) {
|
if (second.equals(ENTRY)) {
|
||||||
state.getCurrentItem().setPubDate(content);
|
state.getCurrentItem().setPubDate(SyndDateUtils.parseRFC3339Date(content));
|
||||||
}
|
}
|
||||||
} else if (top.equals(IMAGE)) {
|
} else if (top.equals(IMAGE)) {
|
||||||
state.getFeed().setImage(new FeedImage(content, null));
|
state.getFeed().setImage(new FeedImage(content, null));
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class NSRSS20 extends Namespace {
|
||||||
state.getCurrentItem().setLink(content);
|
state.getCurrentItem().setLink(content);
|
||||||
}
|
}
|
||||||
} else if (top.equals(PUBDATE) && second.equals(ITEM)) {
|
} else if (top.equals(PUBDATE) && second.equals(ITEM)) {
|
||||||
state.getCurrentItem().setPubDate(content);
|
state.getCurrentItem().setPubDate(SyndDateUtils.parseRFC822Date(content));
|
||||||
} else if (top.equals(URL) && second.equals(IMAGE)) {
|
} else if (top.equals(URL) && second.equals(IMAGE)) {
|
||||||
state.getFeed().getImage().setDownload_url(content);
|
state.getFeed().getImage().setDownload_url(content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,12 @@ public class SyndDateUtils {
|
||||||
Date result = null;
|
Date result = null;
|
||||||
SimpleDateFormat format = null;
|
SimpleDateFormat format = null;
|
||||||
if (date.endsWith("Z")) {
|
if (date.endsWith("Z")) {
|
||||||
format = new SimpleDateFormat(RFC3339UTC);
|
format = new SimpleDateFormat(RFC3339UTC);
|
||||||
|
try {
|
||||||
|
result = format.parse(date);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
format = new SimpleDateFormat(RFC3339LOCAL);
|
format = new SimpleDateFormat(RFC3339LOCAL);
|
||||||
// remove last colon
|
// remove last colon
|
||||||
|
@ -58,13 +63,15 @@ public class SyndDateUtils {
|
||||||
for (int x = 0; x < date.length(); x++) {
|
for (int x = 0; x < date.length(); x++) {
|
||||||
if (x != colonIdx) buf.append(date.charAt(x));
|
if (x != colonIdx) buf.append(date.charAt(x));
|
||||||
}
|
}
|
||||||
String bufStr = buf.toString();
|
String bufStr = buf.toString();
|
||||||
}
|
try {
|
||||||
try {
|
result = format.parse(bufStr);
|
||||||
result = format.parse(date);
|
} catch (ParseException e) {
|
||||||
} catch (ParseException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package de.podfetcher.util;
|
package de.podfetcher.util;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/** Provides methods for converting various units. */
|
/** Provides methods for converting various units. */
|
||||||
|
@ -78,4 +80,9 @@ public final class Converter {
|
||||||
|
|
||||||
return String.format("%02d:%02d", h, m);
|
return String.format("%02d:%02d", h, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns string that is supposed to be shown in the GUI. */
|
||||||
|
public static String getDateString(Date date) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue