summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-07-31 19:46:57 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-07-31 19:46:57 +0200
commitcc7a84ee35712eba18fe2a6fc289392072ccb9d0 (patch)
treeede32bcad46c93f6f5bb99c7a8ef4b7536002a4a /src/de
parentac16f2ad78443b2c57e150058a8f103536605a07 (diff)
downloadAntennaPod-cc7a84ee35712eba18fe2a6fc289392072ccb9d0.zip
Added itemIdentifier attribute
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/feed/FeedItem.java26
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java5
-rw-r--r--src/de/danoeh/antennapod/storage/PodDBAdapter.java12
3 files changed, 40 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedItem.java b/src/de/danoeh/antennapod/feed/FeedItem.java
index 075f58f45..209426b5e 100644
--- a/src/de/danoeh/antennapod/feed/FeedItem.java
+++ b/src/de/danoeh/antennapod/feed/FeedItem.java
@@ -11,6 +11,8 @@ import java.util.Date;
*/
public class FeedItem extends FeedComponent {
+ /** The id/guid that can be found in the rss/atom feed. Might not be set.*/
+ private String itemIdentifier;
private String title;
private String description;
private String contentEncoded;
@@ -58,6 +60,21 @@ public class FeedItem extends FeedComponent {
public SimpleChapter getCurrentChapter() {
return getCurrentChapter(media.getPosition());
}
+
+ /** Returns the value that uniquely identifies this FeedItem.
+ * If the itemIdentifier attribute is not null, it will be returned.
+ * Else it will try to return the link. If the link is not given, it will
+ * use the title of the entry.
+ * */
+ public String getIdentifyingValue() {
+ if (itemIdentifier != null) {
+ return itemIdentifier;
+ } else if (link != null) {
+ return link;
+ } else {
+ return title;
+ }
+ }
public String getTitle() {
return title;
@@ -135,4 +152,13 @@ public class FeedItem extends FeedComponent {
this.simpleChapters = simpleChapters;
}
+ public String getItemIdentifier() {
+ return itemIdentifier;
+ }
+
+ public void setItemIdentifier(String itemIdentifier) {
+ this.itemIdentifier = itemIdentifier;
+ }
+
+
}
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index 324e2268c..be860bd4b 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -654,6 +654,8 @@ public class FeedManager {
}
item.read = (itemlistCursor.getInt(PodDBAdapter.KEY_READ_INDEX) > 0) ? true
: false;
+ item.setItemIdentifier(itemlistCursor
+ .getString(PodDBAdapter.KEY_ITEM_IDENTIFIER_INDEX));
if (!item.read) {
unreadItems.add(item);
}
@@ -675,7 +677,8 @@ public class FeedManager {
.getString(PodDBAdapter.KEY_TITLE_INDEX),
chapterCursor
.getString(PodDBAdapter.KEY_SC_LINK_INDEX));
- chapter.setId(chapterCursor.getLong(PodDBAdapter.KEY_ID_INDEX));
+ chapter.setId(chapterCursor
+ .getLong(PodDBAdapter.KEY_ID_INDEX));
item.getSimpleChapters().add(chapter);
} while (chapterCursor.moveToNext());
}
diff --git a/src/de/danoeh/antennapod/storage/PodDBAdapter.java b/src/de/danoeh/antennapod/storage/PodDBAdapter.java
index 87376ea5c..22745dd90 100644
--- a/src/de/danoeh/antennapod/storage/PodDBAdapter.java
+++ b/src/de/danoeh/antennapod/storage/PodDBAdapter.java
@@ -25,7 +25,7 @@ import android.util.Log;
* */
public class PodDBAdapter {
private static final String TAG = "PodDBAdapter";
- private static final int DATABASE_VERSION = 3;
+ private static final int DATABASE_VERSION = 4;
private static final String DATABASE_NAME = "Antennapod.db";
@@ -52,6 +52,7 @@ public class PodDBAdapter {
public static final int KEY_MEDIA_INDEX = 8;
public static final int KEY_FEED_INDEX = 9;
public static final int KEY_HAS_SIMPLECHAPTERS_INDEX = 10;
+ public static final int KEY_ITEM_IDENTIFIER_INDEX = 11;
// ---------- FeedMedia indices
public static final int KEY_DURATION_INDEX = 1;
public static final int KEY_POSITION_INDEX = 5;
@@ -104,6 +105,7 @@ public class PodDBAdapter {
public static final String KEY_AUTHOR = "author";
public static final String KEY_HAS_SIMPLECHAPTERS = "has_simple_chapters";
public static final String KEY_TYPE = "type";
+ public static final String KEY_ITEM_IDENTIFIER = "item_identifier";
// Table names
public static final String TABLE_NAME_FEEDS = "Feeds";
@@ -145,7 +147,8 @@ public class PodDBAdapter {
KEY_PAYMENT_LINK + " TEXT," +
KEY_MEDIA + " INTEGER," +
KEY_FEED + " INTEGER," +
- KEY_HAS_SIMPLECHAPTERS + " INTEGER)";
+ KEY_HAS_SIMPLECHAPTERS + " INTEGER," +
+ KEY_ITEM_IDENTIFIER + " TEXT)";
private static final String CREATE_TABLE_FEED_IMAGES = "CREATE TABLE "
+ TABLE_NAME_FEED_IMAGES + " (" + TABLE_PRIMARY_KEY +
@@ -346,6 +349,7 @@ public class PodDBAdapter {
values.put(KEY_FEED, item.getFeed().getId());
values.put(KEY_READ, item.isRead());
values.put(KEY_HAS_SIMPLECHAPTERS, item.getSimpleChapters() != null);
+ values.put(KEY_ITEM_IDENTIFIER, item.getItemIdentifier());
if (item.getId() == 0) {
item.setId(db.insert(TABLE_NAME_FEED_ITEMS, null, values));
} else {
@@ -642,6 +646,10 @@ public class PodDBAdapter {
db.execSQL("ALTER TABLE " + TABLE_NAME_SIMPLECHAPTERS + " ADD COLUMN " +
KEY_LINK + " TEXT");
}
+ if (oldVersion <= 3) {
+ db.execSQL("ALTER TABLE " + TABLE_NAME_FEED_ITEMS + " ADD COLUMN " +
+ KEY_ITEM_IDENTIFIER + " TEXT");
+ }
}
}