use of de.danoeh.antennapod.core.feed.VorbisCommentChapter in project AntennaPod by AntennaPod.
the class DBReader method loadChaptersOfFeedItem.
static void loadChaptersOfFeedItem(PodDBAdapter adapter, FeedItem item) {
Cursor chapterCursor = adapter.getSimpleChaptersOfFeedItemCursor(item);
if (chapterCursor.moveToFirst()) {
item.setChapters(new ArrayList<>());
do {
int indexType = chapterCursor.getColumnIndex(PodDBAdapter.KEY_CHAPTER_TYPE);
int indexStart = chapterCursor.getColumnIndex(PodDBAdapter.KEY_START);
int indexTitle = chapterCursor.getColumnIndex(PodDBAdapter.KEY_TITLE);
int indexLink = chapterCursor.getColumnIndex(PodDBAdapter.KEY_LINK);
int chapterType = chapterCursor.getInt(indexType);
Chapter chapter = null;
long start = chapterCursor.getLong(indexStart);
String title = chapterCursor.getString(indexTitle);
String link = chapterCursor.getString(indexLink);
switch(chapterType) {
case SimpleChapter.CHAPTERTYPE_SIMPLECHAPTER:
chapter = new SimpleChapter(start, title, item, link);
break;
case ID3Chapter.CHAPTERTYPE_ID3CHAPTER:
chapter = new ID3Chapter(start, title, item, link);
break;
case VorbisCommentChapter.CHAPTERTYPE_VORBISCOMMENT_CHAPTER:
chapter = new VorbisCommentChapter(start, title, item, link);
break;
}
if (chapter != null) {
int indexId = chapterCursor.getColumnIndex(PodDBAdapter.KEY_ID);
chapter.setId(chapterCursor.getLong(indexId));
item.getChapters().add(chapter);
}
} while (chapterCursor.moveToNext());
} else {
item.setChapters(null);
}
chapterCursor.close();
}
use of de.danoeh.antennapod.core.feed.VorbisCommentChapter in project AntennaPod by AntennaPod.
the class VorbisCommentChapterReader method onContentVectorValue.
@Override
public void onContentVectorValue(String key, String value) throws VorbisCommentReaderException {
if (BuildConfig.DEBUG)
Log.d(TAG, "Key: " + key + ", value: " + value);
String attribute = VorbisCommentChapter.getAttributeTypeFromKey(key);
int id = VorbisCommentChapter.getIDFromKey(key);
Chapter chapter = getChapterById(id);
if (attribute == null) {
if (getChapterById(id) == null) {
// new chapter
long start = VorbisCommentChapter.getStartTimeFromValue(value);
chapter = new VorbisCommentChapter(id);
chapter.setStart(start);
chapters.add(chapter);
} else {
throw new VorbisCommentReaderException("Found chapter with duplicate ID (" + key + ", " + value + ")");
}
} else if (attribute.equals(CHAPTER_ATTRIBUTE_TITLE)) {
if (chapter != null) {
chapter.setTitle(value);
}
} else if (attribute.equals(CHAPTER_ATTRIBUTE_LINK)) {
if (chapter != null) {
chapter.setLink(value);
}
}
}
Aggregations