diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-10-02 19:14:40 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-10-02 19:14:40 -0700 |
commit | d85b982e32737211cdc1f2aab42d718a6cbad1bc (patch) | |
tree | cf9d5db6a422c4d9bd0bc67e2c9a7f4b42ef2b75 /src/github/daneren2005 | |
parent | 6daacadaffd59f14606f0f9110802ae18e0aa086 (diff) | |
download | dsub-d85b982e32737211cdc1f2aab42d718a6cbad1bc.tar.gz dsub-d85b982e32737211cdc1f2aab42d718a6cbad1bc.tar.bz2 dsub-d85b982e32737211cdc1f2aab42d718a6cbad1bc.zip |
Apply conditional cache/delete logic to more fragments
Diffstat (limited to 'src/github/daneren2005')
3 files changed, 34 insertions, 29 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index ac197161..1f5c7b88 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -627,7 +627,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis menu.findItem(R.id.menu_show_artist).setVisible(false);
}
- hideMenuItems(menu);
+ hideMenuItems(menu, (AdapterView.AdapterContextMenuInfo) menuInfo);
}
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index f9ab0cc9..c26429ce 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -19,6 +19,7 @@ package github.daneren2005.dsub.fragments; import android.content.DialogInterface; +import android.util.Log; import android.view.ContextMenu; import android.view.MenuInflater; import android.view.MenuItem; @@ -29,6 +30,7 @@ import github.daneren2005.dsub.R; import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; @@ -39,6 +41,8 @@ import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.BookmarkAdapter; +import github.daneren2005.dsub.view.SongView; + import java.text.Format; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -53,6 +57,8 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En MenuInflater inflater = context.getMenuInflater(); inflater.inflate(R.menu.select_bookmark_context, menu); + + hideMenuItems(menu, (AdapterView.AdapterContextMenuInfo) menuInfo); } @Override diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index d2e20b18..914aa36c 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -207,32 +207,6 @@ 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
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- if(info.targetView instanceof SongView) {
- SongView songView = (SongView) info.targetView;
- 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.song_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 {
@@ -255,10 +229,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
}
- hideMenuItems(menu);
+ hideMenuItems(menu, (AdapterView.AdapterContextMenuInfo) menuInfo);
}
- protected void hideMenuItems(ContextMenu menu) {
+ protected void hideMenuItems(ContextMenu menu, AdapterView.AdapterContextMenuInfo info) {
if(!ServerInfo.checkServerVersion(context, "1.8")) {
menu.setGroupVisible(R.id.server_1_8, false);
menu.setGroupVisible(R.id.hide_star, false);
@@ -286,6 +260,31 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true)) {
menu.setGroupVisible(R.id.hide_rating, false);
}
+
+ // If we are looking at a standard song view, get downloadFile to cache what options to show
+ if(info.targetView instanceof SongView) {
+ SongView songView = (SongView) info.targetView;
+ 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.song_menu_delete);
+ }
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to lookup downloadFile info", e);
+ }
+ }
}
protected void recreateContextMenu(ContextMenu menu) {
|