Added support for 'href' attribute for simple chapters

This commit is contained in:
daniel oeh 2012-07-27 16:55:47 +02:00
parent 83d67a2921
commit 9f84f3733f
4 changed files with 22 additions and 6 deletions

View File

@ -670,7 +670,9 @@ public class FeedManager {
chapterCursor
.getLong(PodDBAdapter.KEY_SC_START_INDEX),
chapterCursor
.getString(PodDBAdapter.KEY_TITLE_INDEX));
.getString(PodDBAdapter.KEY_TITLE_INDEX),
chapterCursor
.getString(PodDBAdapter.KEY_SC_LINK_INDEX));
item.getSimpleChapters().add(chapter);
} while (chapterCursor.moveToNext());
}

View File

@ -5,12 +5,14 @@ public class SimpleChapter extends FeedComponent {
private long start;
private String title;
private FeedItem item;
private String link;
public SimpleChapter(FeedItem item, long start, String title) {
public SimpleChapter(FeedItem item, long start, String title, String link) {
super();
this.item = item;
this.start = start;
this.title = title;
this.link = link;
}
public String getTitle() {
@ -29,4 +31,8 @@ public class SimpleChapter extends FeedComponent {
this.item = item;
}
public String getLink() {
return link;
}
}

View File

@ -25,7 +25,7 @@ import android.util.Log;
* */
public class PodDBAdapter {
private static final String TAG = "PodDBAdapter";
private static final int DATABASE_VERSION = 2;
private static final int DATABASE_VERSION = 3;
private static final String DATABASE_NAME = "Antennapod.db";
@ -69,6 +69,7 @@ public class PodDBAdapter {
// --------- Simplechapters indices
public static final int KEY_SC_START_INDEX = 2;
public static final int KEY_SC_FEEDITEM_INDEX = 3;
public static final int KEY_SC_LINK_INDEX = 4;
// Key-constants
@ -180,7 +181,8 @@ public class PodDBAdapter {
+ TABLE_NAME_SIMPLECHAPTERS + " (" + TABLE_PRIMARY_KEY +
KEY_TITLE + " TEXT," +
KEY_START + " INTEGER," +
KEY_FEEDITEM + " INTEGER)";
KEY_FEEDITEM + " INTEGER," +
KEY_LINK + " TEXT)";
/**
* Used for storing download status entries to determine the type of the
@ -362,6 +364,7 @@ public class PodDBAdapter {
values.put(KEY_TITLE, chapter.getTitle());
values.put(KEY_START, chapter.getStart());
values.put(KEY_FEEDITEM, item.getId());
values.put(KEY_LINK, chapter.getLink());
if (chapter.getId() == 0) {
chapter.setId(db
.insert(TABLE_NAME_SIMPLECHAPTERS, null, values));
@ -631,10 +634,14 @@ public class PodDBAdapter {
final int newVersion) {
Log.w("DBAdapter", "Upgrading from version " + oldVersion + " to "
+ newVersion + ".");
if (oldVersion == 1) {
if (oldVersion <= 1) {
db.execSQL("ALTER TABLE " + TABLE_NAME_FEEDS + " ADD COLUMN " +
KEY_TYPE + " TEXT");
}
if (oldVersion <= 2) {
db.execSQL("ALTER TABLE " + TABLE_NAME_SIMPLECHAPTERS + " ADD COLUMN " +
KEY_LINK + " TEXT");
}
}
}

View File

@ -18,6 +18,7 @@ public class NSSimpleChapters extends Namespace {
public static final String CHAPTER = "chapter";
public static final String START = "start";
public static final String TITLE = "title";
public static final String HREF = "href";
@Override
public SyndElement handleElementStart(String localName, HandlerState state,
@ -31,7 +32,7 @@ public class NSSimpleChapters extends Namespace {
.add(new SimpleChapter(state.getCurrentItem(),
SyndDateUtils.parseTimeString(attributes
.getValue(START)), attributes
.getValue(TITLE)));
.getValue(TITLE), attributes.getValue(HREF)));
}
return new SyndElement(localName, this);