From 5b15bbbd63e77d2a5e82cb20dcc9ff46fea1bf49 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 9 Jul 2013 21:46:04 -0700 Subject: Make podcast channels arrow shaded based on whether any episodes are downloaded --- .../src/github/daneren2005/dsub/util/FileUtil.java | 6 ++++++ .../daneren2005/dsub/view/PodcastChannelView.java | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java index e63b3d76..267db36c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java @@ -37,6 +37,7 @@ import android.os.Environment; import android.util.Log; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.domain.PodcastChannel; /** * @author Sindre Mehus @@ -150,6 +151,11 @@ public class FileUtil { } return dir; } + + public static File getPodcastDirectory(Context context, PodcastChannel channel) { + File dir = new File(getMusicDirectory(context).getPath() + "/" + fileSystemSafe(channel.getName())); + return dir; + } public static void createDirectoryForParent(File file) { File dir = file.getParentFile(); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PodcastChannelView.java b/subsonic-android/src/github/daneren2005/dsub/view/PodcastChannelView.java index 926ba1ba..b51eefb2 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/PodcastChannelView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/PodcastChannelView.java @@ -26,21 +26,28 @@ import android.widget.ImageView; import android.widget.TextView; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.PodcastChannel; +import github.daneren2005.dsub.util.FileUtil; +import java.io.File; public class PodcastChannelView extends UpdateView { private static final String TAG = PodcastChannelView.class.getSimpleName(); + private Context context; + private PodcastChannel channel; + private TextView titleView; + private ImageView moreButton; public PodcastChannelView(Context context) { super(context); + this.context = context; LayoutInflater.from(context).inflate(R.layout.artist_list_item, this, true); titleView = (TextView) findViewById(R.id.artist_name); ImageButton starButton = (ImageButton) findViewById(R.id.artist_star); starButton.setVisibility(View.GONE); starButton.setFocusable(false); - ImageView moreButton = (ImageView) findViewById(R.id.artist_more); + moreButton = (ImageView) findViewById(R.id.artist_more); moreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { v.showContextMenu(); @@ -49,6 +56,17 @@ public class PodcastChannelView extends UpdateView { } public void setPodcastChannel(PodcastChannel podcastChannel) { + channel = podcastChannel; titleView.setText(podcastChannel.getName()); } + + @Override + protected void update() { + File file = FileUtil.getPodcastDirectory(context, channel); + if(file.exists()) { + moreButton.setImageResource(R.drawable.list_item_more_shaded); + } else { + moreButton.setImageResource(R.drawable.list_item_more); + } + } } -- cgit v1.2.3