diff options
Diffstat (limited to 'src/com/p4square/grow/model')
-rw-r--r-- | src/com/p4square/grow/model/Chapter.java | 29 | ||||
-rw-r--r-- | src/com/p4square/grow/model/Playlist.java | 5 |
2 files changed, 30 insertions, 4 deletions
diff --git a/src/com/p4square/grow/model/Chapter.java b/src/com/p4square/grow/model/Chapter.java index 7b6e27c..3a08e4c 100644 --- a/src/com/p4square/grow/model/Chapter.java +++ b/src/com/p4square/grow/model/Chapter.java @@ -17,13 +17,38 @@ import com.fasterxml.jackson.annotation.JsonIgnore; * @author Jesse Morgan <jesse@jesterpm.net> */ public class Chapter implements Cloneable { + private String mName; private Map<String, VideoRecord> mVideos; - public Chapter() { + public Chapter(String name) { + mName = name; mVideos = new HashMap<String, VideoRecord>(); } /** + * Private constructor for JSON decoding. + */ + private Chapter() { + this(null); + } + + /** + * @return The Chapter name. + */ + public String getName() { + return mName; + } + + /** + * Set the chapter name. + * + * @param name The name of the chapter. + */ + public void setName(final String name) { + mName = name; + } + + /** * @return The VideoRecord for videoid or null if videoid is not in the chapter. */ public VideoRecord getVideoRecord(String videoid) { @@ -78,7 +103,7 @@ public class Chapter implements Cloneable { * @return a new Chapter object identical but independent of this one. */ public Chapter clone() throws CloneNotSupportedException { - Chapter c = new Chapter(); + Chapter c = new Chapter(mName); for (Map.Entry<String, VideoRecord> videoEntry : mVideos.entrySet()) { c.setVideoRecord(videoEntry.getKey(), videoEntry.getValue().clone()); } diff --git a/src/com/p4square/grow/model/Playlist.java b/src/com/p4square/grow/model/Playlist.java index b697e66..3e77ada 100644 --- a/src/com/p4square/grow/model/Playlist.java +++ b/src/com/p4square/grow/model/Playlist.java @@ -86,7 +86,7 @@ public class Playlist { Chapter chapter = mPlaylist.get(chapterId); if (chapter == null) { - chapter = new Chapter(); + chapter = new Chapter(chapterId); mPlaylist.put(chapterId, chapter); } @@ -102,6 +102,7 @@ public class Playlist { */ @JsonAnySetter public void addChapter(String chapterId, Chapter chapter) { + chapter.setName(chapterId); mPlaylist.put(chapterId, chapter); } @@ -158,7 +159,7 @@ public class Playlist { if (myChapter == null) { // Add new chapter - myChapter = new Chapter(); + myChapter = new Chapter(chapterName); addChapter(chapterName, myChapter); } |