diff options
Diffstat (limited to 'src/de/danoeh/antennapod/storage/PodDBAdapter.java')
-rw-r--r-- | src/de/danoeh/antennapod/storage/PodDBAdapter.java | 65 |
1 files changed, 35 insertions, 30 deletions
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; } |