Added itemIdentifier attribute
This commit is contained in:
parent
ac16f2ad78
commit
cc7a84ee35
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue