aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-10-02 13:41:50 -0700
committerScott Jackson <daneren2005@gmail.com>2014-10-02 13:41:50 -0700
commit146491ac63dc7beba308997f2c744bdaaed1bc7f (patch)
tree2cb343666539b323da3ffc92c94dca3609224d8b /src/github/daneren2005
parent1704177fbd4327c956d2fdfd5b70c5529c5ae019 (diff)
downloaddsub-146491ac63dc7beba308997f2c744bdaaed1bc7f.tar.gz
dsub-146491ac63dc7beba308997f2c744bdaaed1bc7f.tar.bz2
dsub-146491ac63dc7beba308997f2c744bdaaed1bc7f.zip
Conditionally remove cache/delete menu items depending on status
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index cf6f78b0..2dbf3535 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -74,6 +74,7 @@ import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PlaylistSongView;
+import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
import java.io.File;
@@ -205,6 +206,31 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
if(entry.getBookmark() == null) {
menu.removeItem(R.id.bookmark_menu_delete);
}
+
+ // If we are looking at a standard song view, get downloadFile to cache what options to show
+ if(view instanceof SongView) {
+ SongView songView = (SongView) view;
+ DownloadFile downloadFile = songView.getDownloadFile();
+
+ try {
+ if(downloadFile != null) {
+ if(downloadFile.isWorkDone()) {
+ // Remove permanent cache menu if already perma cached
+ if(downloadFile.isSaved()) {
+ menu.removeItem(R.id.song_menu_pin);
+ }
+
+ // Remove cache option no matter what if already downloaded
+ menu.removeItem(R.id.song_menu_download);
+ } else {
+ // Remove delete option if nothing to delete
+ menu.removeItem(R.id.menu_delete);
+ }
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to lookup downloadFile info", e);
+ }
+ }
}
menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star);
} else {