diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-09-21 19:00:49 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-09-21 19:00:49 +0200 |
commit | 0eb841db4b2c340c5c5200e5fb655482ee98cfc6 (patch) | |
tree | 0d0902e6f4d681f6634a5da7d7d763ddd9ff55ff /src/de/danoeh/antennapod/feed | |
parent | 2ebef34408570b68d7ef9b16afb8887698d2eee3 (diff) | |
download | AntennaPod-0eb841db4b2c340c5c5200e5fb655482ee98cfc6.zip |
Integrated id3 chapterreader in Antennapod
Diffstat (limited to 'src/de/danoeh/antennapod/feed')
-rw-r--r-- | src/de/danoeh/antennapod/feed/Chapter.java | 23 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/feed/FeedManager.java | 28 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/feed/ID3Chapter.java | 36 |
3 files changed, 77 insertions, 10 deletions
diff --git a/src/de/danoeh/antennapod/feed/Chapter.java b/src/de/danoeh/antennapod/feed/Chapter.java index b44723d8e..f50053f93 100644 --- a/src/de/danoeh/antennapod/feed/Chapter.java +++ b/src/de/danoeh/antennapod/feed/Chapter.java @@ -1,6 +1,6 @@ package de.danoeh.antennapod.feed; -public abstract class Chapter extends FeedComponent{ +public abstract class Chapter extends FeedComponent { /** Defines starting point in milliseconds. */ protected long start; @@ -8,6 +8,11 @@ public abstract class Chapter extends FeedComponent{ protected FeedItem item; protected String link; + public Chapter(long start) { + super(); + this.start = start; + } + public Chapter(long start, String title, FeedItem item, String link) { super(); this.start = start; @@ -34,4 +39,20 @@ public abstract class Chapter extends FeedComponent{ return link; } + public void setStart(long start) { + this.start = start; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setItem(FeedItem item) { + this.item = item; + } + + public void setLink(String link) { + this.link = link; + } + } diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index 526334b2b..1c6d7036f 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -374,13 +374,13 @@ public class FeedManager { downloadFeedItem(context, queue.toArray(new FeedItem[queue.size()])); } } - + public void downloadFeedItem(final Context context, FeedItem... items) { boolean autoQueue = PreferenceManager.getDefaultSharedPreferences( context.getApplicationContext()).getBoolean( PodcastApp.PREF_AUTO_QUEUE, true); List<FeedItem> addToQueue = new ArrayList<FeedItem>(); - + for (FeedItem item : items) { if (item.getMedia() != null && !requester.isDownloadingFile(item.getMedia()) @@ -390,7 +390,8 @@ public class FeedManager { } } if (autoQueue) { - addQueueItem(context, addToQueue.toArray(new FeedItem[addToQueue.size()])); + addQueueItem(context, + addToQueue.toArray(new FeedItem[addToQueue.size()])); } } @@ -921,15 +922,24 @@ public class FeedManager { if (chapterCursor.moveToFirst()) { item.setChapters(new ArrayList<Chapter>()); do { - int chapterType = chapterCursor.getInt(PodDBAdapter.KEY_CHAPTER_TYPE_INDEX); + int chapterType = chapterCursor + .getInt(PodDBAdapter.KEY_CHAPTER_TYPE_INDEX); Chapter chapter = null; - long start = chapterCursor.getLong(PodDBAdapter.KEY_CHAPTER_START_INDEX); - String title = chapterCursor.getString(PodDBAdapter.KEY_TITLE_INDEX); - String link = chapterCursor.getString(PodDBAdapter.KEY_CHAPTER_LINK_INDEX); - + long start = chapterCursor + .getLong(PodDBAdapter.KEY_CHAPTER_START_INDEX); + String title = chapterCursor + .getString(PodDBAdapter.KEY_TITLE_INDEX); + String link = chapterCursor + .getString(PodDBAdapter.KEY_CHAPTER_LINK_INDEX); + switch (chapterType) { case SimpleChapter.CHAPTERTYPE_SIMPLECHAPTER: - chapter = new SimpleChapter(start, title, item, link); + chapter = new SimpleChapter(start, title, item, + link); + break; + case ID3Chapter.CHAPTERTYPE_ID3CHAPTER: + chapter = new ID3Chapter(start, title, item, + link); break; } chapter.setId(chapterCursor diff --git a/src/de/danoeh/antennapod/feed/ID3Chapter.java b/src/de/danoeh/antennapod/feed/ID3Chapter.java new file mode 100644 index 000000000..6dde7854e --- /dev/null +++ b/src/de/danoeh/antennapod/feed/ID3Chapter.java @@ -0,0 +1,36 @@ +package de.danoeh.antennapod.feed; + +public class ID3Chapter extends Chapter { + public static final int CHAPTERTYPE_ID3CHAPTER = 2; + + /** + * Identifies the chapter in its ID3 tag. This attribute does not have to be + * store in the DB and is only used for parsing. + */ + private String id3ID; + + public ID3Chapter(String id3ID, long start) { + super(start); + this.id3ID = id3ID; + } + + public ID3Chapter(long start, String title, FeedItem item, String link) { + super(start, title, item, link); + } + + @Override + public String toString() { + return "ID3Chapter [id3ID=" + id3ID + ", title=" + title + ", start=" + + start + ", url=" + link + "]"; + } + + @Override + public int getChapterType() { + return CHAPTERTYPE_ID3CHAPTER; + } + + public String getId3ID() { + return id3ID; + } + +} |