From 93d03bc7ab2b078e48baad33257606e06875f994 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 30 Apr 2013 21:44:33 -0700 Subject: Merge callbacks for artists so search fragment can use them --- .../dsub/fragments/SelectArtistFragment.java | 32 +--------------------- .../dsub/fragments/SubsonicFragment.java | 26 ++++++++++++++++++ 2 files changed, 27 insertions(+), 31 deletions(-) (limited to 'subsonic-android/src/github/daneren2005') diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java index df49086d..95452eb6 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -113,32 +113,10 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie } AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); - Artist artist = (Artist) artistList.getItemAtPosition(info.position); if (artist != null) { - switch (menuItem.getItemId()) { - case R.id.artist_menu_play_now: - downloadRecursively(artist.getId(), false, false, true, false, false); - break; - case R.id.artist_menu_play_shuffled: - downloadRecursively(artist.getId(), false, false, true, true, false); - break; - case R.id.artist_menu_play_last: - downloadRecursively(artist.getId(), false, true, false, false, false); - break; - case R.id.artist_menu_download: - downloadRecursively(artist.getId(), false, true, false, false, true); - break; - case R.id.artist_menu_pin: - downloadRecursively(artist.getId(), true, true, false, false, true); - break; - case R.id.artist_menu_delete: - deleteRecursively(artist); - break; - default: - return super.onContextItemSelected(menuItem); - } + return onContextItemSelected(menuItem, artist); } else if (info.position == 0) { MusicFolder selectedFolder = menuItem.getItemId() == -1 ? null : musicFolders.get(menuItem.getItemId()); String musicFolderId = selectedFolder == null ? null : selectedFolder.getId(); @@ -217,12 +195,4 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie private void selectFolder() { folderButton.showContextMenu(); } - - public void deleteRecursively(Artist artist) { - File dir = FileUtil.getArtistDirectory(context, artist); - Util.recursiveDelete(dir); - if(Util.isOffline(context)) { - refresh(); - } - } } diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 09d0e5d5..1284a99a 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -171,6 +171,24 @@ public class SubsonicFragment extends SherlockFragment { songs.add(entry); switch (menuItem.getItemId()) { + case R.id.artist_menu_play_now: + downloadRecursively(artist.getId(), false, false, true, false, false); + break; + case R.id.artist_menu_play_shuffled: + downloadRecursively(artist.getId(), false, false, true, true, false); + break; + case R.id.artist_menu_play_last: + downloadRecursively(artist.getId(), false, true, false, false, false); + break; + case R.id.artist_menu_download: + downloadRecursively(artist.getId(), false, true, false, false, true); + break; + case R.id.artist_menu_pin: + downloadRecursively(artist.getId(), true, true, false, false, true); + break; + case R.id.artist_menu_delete: + deleteRecursively(artist); + break; case R.id.album_menu_play_now: downloadRecursively(entry.getId(), false, false, true, false, false); break; @@ -688,6 +706,14 @@ public class SubsonicFragment extends SherlockFragment { return check.isCompleteFileAvailable(); } + public void deleteRecursively(Artist artist) { + File dir = FileUtil.getArtistDirectory(context, artist); + Util.recursiveDelete(dir); + if(Util.isOffline(context)) { + refresh(); + } + } + public void deleteRecursively(MusicDirectory.Entry album) { File dir = FileUtil.getAlbumDirectory(context, album); Util.recursiveDelete(dir); -- cgit v1.2.3