use of de.danoeh.antennapod.parser.media.vorbis.VorbisCommentChapter in project AntennaPod by AntennaPod.
the class ChapterCursorMapper method convert.
/**
* Create a {@link Chapter} instance from a database row (cursor).
*/
@NonNull
public static Chapter convert(@NonNull Cursor cursor) {
int indexId = cursor.getColumnIndex(PodDBAdapter.KEY_ID);
int indexTitle = cursor.getColumnIndex(PodDBAdapter.KEY_TITLE);
int indexStart = cursor.getColumnIndex(PodDBAdapter.KEY_START);
int indexLink = cursor.getColumnIndex(PodDBAdapter.KEY_LINK);
int indexImage = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE_URL);
int indexChapterType = cursor.getColumnIndex(PodDBAdapter.KEY_CHAPTER_TYPE);
long id = cursor.getLong(indexId);
String title = cursor.getString(indexTitle);
long start = cursor.getLong(indexStart);
String link = cursor.getString(indexLink);
String imageUrl = cursor.getString(indexImage);
int chapterType = cursor.getInt(indexChapterType);
Chapter chapter;
switch(chapterType) {
case SimpleChapter.CHAPTERTYPE_SIMPLECHAPTER:
chapter = new SimpleChapter(start, title, link, imageUrl);
break;
case ID3Chapter.CHAPTERTYPE_ID3CHAPTER:
chapter = new ID3Chapter(start, title, link, imageUrl);
break;
case VorbisCommentChapter.CHAPTERTYPE_VORBISCOMMENT_CHAPTER:
chapter = new VorbisCommentChapter(start, title, link, imageUrl);
break;
default:
throw new IllegalArgumentException("Unknown chapter type");
}
chapter.setId(id);
return chapter;
}
Aggregations