diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-10-04 10:59:35 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-10-04 10:59:35 -0700 |
commit | 585ce314976f7afdc48cee40ebc6a401e4fd3f73 (patch) | |
tree | 9180e6756f5075d309ac6620cf45a7b991cdf6a5 | |
parent | b798b02d91e42ee449a4f635f1a5598a61f15ab7 (diff) | |
download | dsub-585ce314976f7afdc48cee40ebc6a401e4fd3f73.tar.gz dsub-585ce314976f7afdc48cee40ebc6a401e4fd3f73.tar.bz2 dsub-585ce314976f7afdc48cee40ebc6a401e4fd3f73.zip |
Conditionally remove delete from directory context menus
5 files changed, 23 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 2b9767c2..67bef249 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -74,6 +74,10 @@ import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
+import github.daneren2005.dsub.view.AlbumCell;
+import github.daneren2005.dsub.view.AlbumView;
+import github.daneren2005.dsub.view.ArtistEntryView;
+import github.daneren2005.dsub.view.ArtistView;
import github.daneren2005.dsub.view.PlaylistSongView;
import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
@@ -289,8 +293,8 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR // Apply similar logic to album views
else if(info.targetView instanceof AlbumCell || info.targetView instanceof AlbumView
|| info.targetView instanceof ArtistView || info.targetView instanceof ArtistEntryView) {
- File folder;
- int id;
+ File folder = null;
+ int id = 0;
if(info.targetView instanceof AlbumCell) {
folder = ((AlbumCell) info.targetView).getFile();
id = R.id.album_menu_delete;
@@ -306,7 +310,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
try {
- if(!folder.exists()) {
+ if(folder != null && !folder.exists()) {
menu.removeItem(id);
}
} catch(Exception e) {
diff --git a/src/github/daneren2005/dsub/view/AlbumCell.java b/src/github/daneren2005/dsub/view/AlbumCell.java index d6a18205..110456e7 100644 --- a/src/github/daneren2005/dsub/view/AlbumCell.java +++ b/src/github/daneren2005/dsub/view/AlbumCell.java @@ -101,4 +101,8 @@ public class AlbumCell extends UpdateView { public MusicDirectory.Entry getEntry() {
return album;
}
+
+ public File getFile() {
+ return file;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java index 7785a8af..70c1e049 100644 --- a/src/github/daneren2005/dsub/view/AlbumView.java +++ b/src/github/daneren2005/dsub/view/AlbumView.java @@ -100,4 +100,8 @@ public class AlbumView extends UpdateView { public MusicDirectory.Entry getEntry() {
return album;
}
+
+ public File getFile() {
+ return file;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/ArtistEntryView.java b/src/github/daneren2005/dsub/view/ArtistEntryView.java index 86fe7b1f..157b25a9 100644 --- a/src/github/daneren2005/dsub/view/ArtistEntryView.java +++ b/src/github/daneren2005/dsub/view/ArtistEntryView.java @@ -72,4 +72,8 @@ public class ArtistEntryView extends UpdateView { exists = file.exists();
isStarred = artist.isStarred();
}
+
+ public File getFile() {
+ return file;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/ArtistView.java b/src/github/daneren2005/dsub/view/ArtistView.java index 23ce4f9d..b8a87c20 100644 --- a/src/github/daneren2005/dsub/view/ArtistView.java +++ b/src/github/daneren2005/dsub/view/ArtistView.java @@ -71,4 +71,8 @@ public class ArtistView extends UpdateView { exists = file.exists();
isStarred = artist.isStarred();
}
+
+ public File getFile() {
+ return file;
+ }
}
|