aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-11-07 11:34:52 -0800
committerScott Jackson <daneren2005@gmail.com>2015-11-07 11:34:52 -0800
commitf0be095e584d7391ef5c83779b6fe7410109cac9 (patch)
tree38ee7396c483c9cd458616e035d7e99162c2a929 /app/src/main
parente947075d218e8ad4176a2a4ec384d6f1ef67e78b (diff)
downloaddsub-f0be095e584d7391ef5c83779b6fe7410109cac9.tar.gz
dsub-f0be095e584d7391ef5c83779b6fe7410109cac9.tar.bz2
dsub-f0be095e584d7391ef5c83779b6fe7410109cac9.zip
Add podcast channel to Newest Episode listing
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java23
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/SongView.java15
3 files changed, 38 insertions, 4 deletions
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<Serializable> 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<MusicDirectory.Entry, Boolean> {
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<MusicDirectory.Entry, Boolean> {
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<MusicDirectory.Entry, Boolean> {
public MusicDirectory.Entry getEntry() {
return item;
}
+
+ public void setShowPodcast(boolean showPodcast) {
+ this.showPodcast = showPodcast;
+ }
}