summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java22
-rw-r--r--src/de/danoeh/antennapod/storage/PodDBAdapter.java65
2 files changed, 44 insertions, 43 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index d9b4e6c56..955422ee5 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -1129,37 +1129,33 @@ public class FeedManager {
do {
FeedItem item = new FeedItem();
- item.id = itemlistCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
+ item.id = itemlistCursor.getLong(PodDBAdapter.IDX_FI_SMALL_ID);
item.setFeed(feed);
item.setTitle(itemlistCursor
- .getString(PodDBAdapter.KEY_TITLE_INDEX));
+ .getString(PodDBAdapter.IDX_FI_SMALL_TITLE));
item.setLink(itemlistCursor
- .getString(PodDBAdapter.KEY_LINK_INDEX));
- item.setDescription(itemlistCursor
- .getString(PodDBAdapter.KEY_DESCRIPTION_INDEX));
- item.setContentEncoded(itemlistCursor
- .getString(PodDBAdapter.KEY_CONTENT_ENCODED_INDEX));
+ .getString(PodDBAdapter.IDX_FI_SMALL_LINK));
item.setPubDate(new Date(itemlistCursor
- .getLong(PodDBAdapter.KEY_PUBDATE_INDEX)));
+ .getLong(PodDBAdapter.IDX_FI_SMALL_PUBDATE)));
item.setPaymentLink(itemlistCursor
- .getString(PodDBAdapter.KEY_PAYMENT_LINK_INDEX));
+ .getString(PodDBAdapter.IDX_FI_SMALL_PAYMENT_LINK));
long mediaId = itemlistCursor
- .getLong(PodDBAdapter.KEY_MEDIA_INDEX);
+ .getLong(PodDBAdapter.IDX_FI_SMALL_MEDIA);
if (mediaId != 0) {
mediaIds.add(String.valueOf(mediaId));
item.setMedia(new FeedMedia(mediaId, item));
}
- item.read = (itemlistCursor.getInt(PodDBAdapter.KEY_READ_INDEX) > 0) ? true
+ item.read = (itemlistCursor.getInt(PodDBAdapter.IDX_FI_SMALL_READ) > 0) ? true
: false;
item.setItemIdentifier(itemlistCursor
- .getString(PodDBAdapter.KEY_ITEM_IDENTIFIER_INDEX));
+ .getString(PodDBAdapter.IDX_FI_SMALL_ITEM_IDENTIFIER));
if (!item.read) {
unreadItems.add(item);
}
// extract chapters
boolean hasSimpleChapters = itemlistCursor
- .getInt(PodDBAdapter.KEY_HAS_SIMPLECHAPTERS_INDEX) > 0;
+ .getInt(PodDBAdapter.IDX_FI_SMALL_HAS_CHAPTERS) > 0;
if (hasSimpleChapters) {
Cursor chapterCursor = adapter
.getSimpleChaptersOfFeedItemCursor(item);
diff --git a/src/de/danoeh/antennapod/storage/PodDBAdapter.java b/src/de/danoeh/antennapod/storage/PodDBAdapter.java
index 7b7b1b1e3..efe1704b7 100644
--- a/src/de/danoeh/antennapod/storage/PodDBAdapter.java
+++ b/src/de/danoeh/antennapod/storage/PodDBAdapter.java
@@ -180,22 +180,16 @@ public class PodDBAdapter {
private final Context context;
private PodDBHelper helper;
- /** Select all columns from the feeditems-table except description and content-encoded. */
- private static final String[] SEL_FI_SMALL = {
- KEY_ID,
- KEY_TITLE,
- KEY_PUBDATE,
- KEY_READ,
- KEY_LINK,
- KEY_PAYMENT_LINK,
- KEY_MEDIA,
- KEY_FEED,
- KEY_HAS_CHAPTERS,
- KEY_ITEM_IDENTIFIER
- };
-
+ /**
+ * Select all columns from the feeditems-table except description and
+ * content-encoded.
+ */
+ private static final String[] SEL_FI_SMALL = { KEY_ID, KEY_TITLE,
+ KEY_PUBDATE, KEY_READ, KEY_LINK, KEY_PAYMENT_LINK, KEY_MEDIA,
+ KEY_FEED, KEY_HAS_CHAPTERS, KEY_ITEM_IDENTIFIER };
+
// column indices for SEL_FI_SMALL
-
+
public static final int IDX_FI_SMALL_ID = 0;
public static final int IDX_FI_SMALL_TITLE = 1;
public static final int IDX_FI_SMALL_PUBDATE = 2;
@@ -208,18 +202,15 @@ public class PodDBAdapter {
public static final int IDX_FI_SMALL_ITEM_IDENTIFIER = 9;
/** Select id, description and content-encoded column from feeditems. */
- public static final String[] SEL_FI_EXTRA = {
- KEY_ID,
- KEY_DESCRIPTION,
- KEY_CONTENT_ENCODED
- };
-
- //column indices for SEL_FI_EXTRA
-
+ public static final String[] SEL_FI_EXTRA = { KEY_ID, KEY_DESCRIPTION,
+ KEY_CONTENT_ENCODED };
+
+ // column indices for SEL_FI_EXTRA
+
public static final int IDX_FI_EXTRA_ID = 0;
public static final int IDX_FI_EXTRA_DESCRIPTION = 1;
public static final int IDX_FI_EXTRA_CONTENT_ENCODED = 2;
-
+
public PodDBAdapter(Context c) {
this.context = c;
helper = new PodDBHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
@@ -320,7 +311,8 @@ public class PodDBAdapter {
values.put(KEY_DOWNLOADED, media.isDownloaded());
values.put(KEY_FILE_URL, media.getFile_url());
if (media.getPlaybackCompletionDate() != null) {
- values.put(KEY_PLAYBACK_COMPLETION_DATE, media.getPlaybackCompletionDate().getTime());
+ values.put(KEY_PLAYBACK_COMPLETION_DATE, media
+ .getPlaybackCompletionDate().getTime());
} else {
values.put(KEY_PLAYBACK_COMPLETION_DATE, 0);
}
@@ -364,8 +356,12 @@ public class PodDBAdapter {
ContentValues values = new ContentValues();
values.put(KEY_TITLE, item.getTitle());
values.put(KEY_LINK, item.getLink());
- values.put(KEY_DESCRIPTION, item.getDescription());
- values.put(KEY_CONTENT_ENCODED, item.getContentEncoded());
+ if (item.getDescription() != null) {
+ values.put(KEY_DESCRIPTION, item.getDescription());
+ }
+ if (item.getContentEncoded() != null) {
+ values.put(KEY_CONTENT_ENCODED, item.getContentEncoded());
+ }
values.put(KEY_PUBDATE, item.getPubDate().getTime());
values.put(KEY_PAYMENT_LINK, item.getPaymentLink());
if (item.getMedia() != null) {
@@ -511,7 +507,7 @@ public class PodDBAdapter {
}
/**
- * Returns a cursor with all FeedItems of a Feed.
+ * Returns a cursor with all FeedItems of a Feed. Uses SEL_FI_SMALL
*
* @param feed
* The feed you want to get the FeedItems from.
@@ -519,9 +515,18 @@ public class PodDBAdapter {
* */
public final Cursor getAllItemsOfFeedCursor(final Feed feed) {
open();
+ Cursor c = db.query(TABLE_NAME_FEED_ITEMS, SEL_FI_SMALL, KEY_FEED
+ + "=?", new String[] { String.valueOf(feed.getId()) }, null,
+ null, null);
+ return c;
+ }
+
+ /** Return a cursor with the SEL_FI_EXTRA selection of a single feeditem. */
+ public final Cursor getExtraInformationOfItem(final FeedItem item) {
+ open();
Cursor c = db
- .query(TABLE_NAME_FEED_ITEMS, null, KEY_FEED + "=?",
- new String[] { String.valueOf(feed.getId()) }, null,
+ .query(TABLE_NAME_FEED_ITEMS, SEL_FI_EXTRA, KEY_ID + "=?",
+ new String[] { String.valueOf(item.getId()) }, null,
null, null);
return c;
}