From f0be095e584d7391ef5c83779b6fe7410109cac9 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 7 Nov 2015 11:34:52 -0800 Subject: Add podcast channel to Newest Episode listing --- .../dsub/adapter/PodcastChannelAdapter.java | 4 +++- .../dsub/service/parser/PodcastEntryParser.java | 23 ++++++++++++++++++++-- .../github/daneren2005/dsub/view/SongView.java | 15 +++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java index de4dffa6..a95abeda 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java @@ -82,8 +82,10 @@ public class PodcastChannelAdapter extends SectionAdapter implemen @Override public void onBindViewHolder(UpdateView.UpdateViewHolder holder, Serializable item, int viewType) { if(viewType == VIEW_TYPE_PODCAST_EPISODE) { + SongView songView = (SongView) holder.getUpdateView(); PodcastEpisode episode = (PodcastEpisode) item; - holder.getUpdateView().setObject(item, !episode.isVideo()); + songView.setShowPodcast(true); + songView.setObject(episode, !episode.isVideo()); } else { holder.getUpdateView().setObject(item); } diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java index 34a5bffc..ca9b609c 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java +++ b/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java @@ -65,8 +65,27 @@ public class PodcastEntryParser extends AbstractParser { episode.setEpisodeId(get("id")); episode.setId(get("streamId")); episode.setTitle(get("title")); - episode.setParent(episodes.getId()); - episode.setArtist(episodes.getName()); + if(episodes.getName() != null) { + episode.setArtist(episodes.getName()); + episode.setParent(episodes.getId()); + } else { + String artist = get("artist"); + String album = get("album"); + + String podcast; + if ("Podcasts".equals(artist)) { + podcast = album; + } else if("Podcast".equals(album)) { + podcast = artist; + } else if(album != null) { + podcast = album; + } else { + podcast = artist; + } + + episode.setArtist(podcast); + episode.setParent(get("channelId")); + } episode.setAlbum(get("description")); episode.setDate(get("publishDate")); if(episode.getDate() == null) { diff --git a/app/src/main/java/github/daneren2005/dsub/view/SongView.java b/app/src/main/java/github/daneren2005/dsub/view/SongView.java index 1027905a..625303b7 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/SongView.java +++ b/app/src/main/java/github/daneren2005/dsub/view/SongView.java @@ -64,6 +64,7 @@ public class SongView extends UpdateView2 { private boolean loaded = false; private boolean isBookmarked = false; private boolean bookmarked = false; + private boolean showPodcast = false; public SongView(Context context) { super(context); @@ -91,8 +92,16 @@ public class SongView extends UpdateView2 { boolean isPodcast = song instanceof PodcastEpisode; if(!song.isVideo() || isPodcast) { if(isPodcast) { - String date = ((PodcastEpisode)song).getDate(); + PodcastEpisode episode = (PodcastEpisode) song; + if(showPodcast && episode.getArtist() != null) { + artist.append(episode.getArtist()); + } + + String date = episode.getDate(); if(date != null) { + if(artist.length() != 0) { + artist.append(" - "); + } int index = date.indexOf(" "); artist.append(date.substring(0, index != -1 ? index : date.length())); } @@ -291,4 +300,8 @@ public class SongView extends UpdateView2 { public MusicDirectory.Entry getEntry() { return item; } + + public void setShowPodcast(boolean showPodcast) { + this.showPodcast = showPodcast; + } } -- cgit v1.2.3