Artist intent

This commit is contained in:
Joshua Bahnsen 2013-07-17 23:01:05 -07:00
parent 0d3dc321f4
commit fd82b195e1
4 changed files with 70 additions and 45 deletions

View File

@ -208,22 +208,22 @@ public class SearchActivity extends SubsonicTabActivity {
switch (menuItem.getItemId()) {
case R.id.album_menu_play_now:
downloadRecursively(id, false, false, true, false, false, false, false);
downloadRecursively(id, false, false, true, false, false, false, false, false);
break;
case R.id.album_menu_play_next:
downloadRecursively(id, false, true, false, true, false, true, false);
downloadRecursively(id, false, true, false, true, false, true, false, false);
break;
case R.id.album_menu_play_last:
downloadRecursively(id, false, true, false, false, false, false, false);
downloadRecursively(id, false, true, false, false, false, false, false, false);
break;
case R.id.album_menu_pin:
downloadRecursively(id, true, true, false, false, false, false, false);
downloadRecursively(id, true, true, false, false, false, false, false, false);
break;
case R.id.album_menu_unpin:
downloadRecursively(id, false, false, false, false, false, false, true);
downloadRecursively(id, false, false, false, false, false, false, true, false);
break;
case R.id.album_menu_download:
downloadRecursively(id, false, false, false, false, true, false, false);
downloadRecursively(id, false, false, false, false, true, false, false, false);
break;
case R.id.song_menu_play_now:
if (entry != null) {

View File

@ -278,7 +278,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID);
if (hasSubFolders && id != null) {
downloadRecursively(id, false, append, !append, shuffle, false, false, false);
downloadRecursively(id, false, append, !append, shuffle, false, false, false, false);
} else {
selectAll(true, false);
download(append, false, !append, false, shuffle, getSelectedSongs(albumListView));
@ -337,22 +337,22 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
switch (menuItem.getItemId()) {
case R.id.album_menu_play_now:
downloadRecursively(entry.getId(), false, false, true, false, false, false, false);
downloadRecursively(entry.getId(), false, false, true, false, false, false, false, false);
break;
case R.id.album_menu_play_next:
downloadRecursively(entry.getId(), false, false, false, false, false, true, false);
downloadRecursively(entry.getId(), false, false, false, false, false, true, false, false);
break;
case R.id.album_menu_play_last:
downloadRecursively(entry.getId(), false, true, false, false, false, false, false);
downloadRecursively(entry.getId(), false, true, false, false, false, false, false, false);
break;
case R.id.album_menu_pin:
downloadRecursively(entry.getId(), true, true, false, false, false, false, false);
downloadRecursively(entry.getId(), true, true, false, false, false, false, false, false);
break;
case R.id.album_menu_unpin:
downloadRecursively(entry.getId(), false, false, false, false, false, false, true);
downloadRecursively(entry.getId(), false, false, false, false, false, false, true, false);
break;
case R.id.album_menu_download:
downloadRecursively(entry.getId(), false, false, false, false, true, false, false);
downloadRecursively(entry.getId(), false, false, false, false, true, false, false, false);
break;
case R.id.select_album_play_all:
playAll();

View File

@ -192,6 +192,7 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
Intent intent = new Intent(this, SelectAlbumActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
intent.putExtra(Constants.INTENT_EXTRA_NAME_ARTIST, true);
Util.startActivityWithoutTransition(this, intent);
}
}
@ -239,22 +240,22 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
if (artist != null) {
switch (menuItem.getItemId()) {
case R.id.artist_menu_play_now:
downloadRecursively(artist.getId(), false, false, true, false, false, false, false);
downloadRecursively(artist.getId(), false, false, true, false, false, false, false, true);
break;
case R.id.artist_menu_play_next:
downloadRecursively(artist.getId(), false, false, true, true, false, true, false);
downloadRecursively(artist.getId(), false, false, true, true, false, true, false, true);
break;
case R.id.artist_menu_play_last:
downloadRecursively(artist.getId(), false, true, false, false, false, false, false);
downloadRecursively(artist.getId(), false, true, false, false, false, false, false, true);
break;
case R.id.artist_menu_pin:
downloadRecursively(artist.getId(), true, true, false, false, false, false, false);
downloadRecursively(artist.getId(), true, true, false, false, false, false, false, true);
break;
case R.id.artist_menu_unpin:
downloadRecursively(artist.getId(), false, false, false, false, false, false, true);
downloadRecursively(artist.getId(), false, false, false, false, false, false, true, true);
break;
case R.id.artist_menu_download:
downloadRecursively(artist.getId(), false, false, false, false, true, false, false);
downloadRecursively(artist.getId(), false, false, false, false, true, false, false, true);
break;
default:
return super.onContextItemSelected(menuItem);

View File

@ -643,34 +643,38 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
checkLicenseAndTrialPeriod(onValid);
}
protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext, final boolean unpin) {
downloadRecursively(id, "", true, save, append, autoplay, shuffle, background, playNext, unpin);
protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext, final boolean unpin, final boolean isArtist) {
downloadRecursively(id, "", true, save, append, autoplay, shuffle, background, playNext, unpin, isArtist);
}
protected void downloadPlaylist(final String id, final String name, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext, final boolean unpin) {
downloadRecursively(id, name, false, save, append, autoplay, shuffle, background, playNext, unpin);
protected void downloadPlaylist(final String id, final String name, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext, final boolean unpin) {
downloadRecursively(id, name, false, save, append, autoplay, shuffle, background, playNext, unpin, false);
}
protected void downloadRecursively(final String id, final String name, final boolean isDirectory, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext, final boolean unpin) {
ModalBackgroundTask<List<MusicDirectory.Entry>> task = new ModalBackgroundTask<List<MusicDirectory.Entry>>(this, false) {
protected void downloadRecursively(final String id, final String name, final boolean isDirectory, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext, final boolean unpin, final boolean isArtist) {
ModalBackgroundTask<List<MusicDirectory.Entry>> task = new ModalBackgroundTask<List<MusicDirectory.Entry>>(this, false) {
private static final int MAX_SONGS = 500;
@Override
protected List<MusicDirectory.Entry> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(SubsonicTabActivity.this);
MusicDirectory root;
if(isDirectory) {
if (Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
root = musicService.getAlbum(id, name, false, SubsonicTabActivity.this, this);
} else {
root = musicService.getMusicDirectory(id, name, false, SubsonicTabActivity.this, this);
}
} else {
root = musicService.getPlaylist(id, name, SubsonicTabActivity.this, this);
}
List<MusicDirectory.Entry> songs = new LinkedList<MusicDirectory.Entry>();
getSongsRecursively(root, songs);
MusicDirectory root;
if (isArtist && Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
getSongsForArtist(id, songs);
} else {
if (isDirectory) {
if (Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
root = musicService.getAlbum(id, name, false, SubsonicTabActivity.this, this);
} else {
root = musicService.getMusicDirectory(id, name, false, SubsonicTabActivity.this, this);
}
} else {
root = musicService.getPlaylist(id, name, SubsonicTabActivity.this, this);
}
getSongsRecursively(root, songs);
}
return songs;
}
@ -684,21 +688,41 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
songs.add(song);
}
}
MusicService musicService = MusicServiceFactory.getMusicService(SubsonicTabActivity.this);
for (MusicDirectory.Entry dir : parent.getChildren(true, false)) {
MusicService musicService = MusicServiceFactory.getMusicService(SubsonicTabActivity.this);
MusicDirectory root;
if (Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
root = musicService.getAlbum(dir.getId(), dir.getTitle(), false, SubsonicTabActivity.this, this);
root = musicService.getAlbum(dir.getId(), dir.getTitle(), false, SubsonicTabActivity.this, this);
} else {
root = musicService.getMusicDirectory(dir.getId(), dir.getTitle(), false, SubsonicTabActivity.this, this);
root = musicService.getMusicDirectory(dir.getId(), dir.getTitle(), false, SubsonicTabActivity.this, this);
}
getSongsRecursively(root, songs);
}
}
private void getSongsForArtist(String id, List<MusicDirectory.Entry> songs) throws Exception {
if (songs.size() > MAX_SONGS) {
return;
}
MusicService musicService = MusicServiceFactory.getMusicService(SubsonicTabActivity.this);
MusicDirectory artist = musicService.getArtist(id, "", false, SubsonicTabActivity.this, this);
for (MusicDirectory.Entry album : artist.getChildren()) {
MusicDirectory albumDirectory = musicService.getAlbum(album.getId(), "", false, SubsonicTabActivity.this, this);
for (MusicDirectory.Entry song : albumDirectory.getChildren()) {
if (!song.isVideo()) {
songs.add(song);
}
}
}
}
@Override
protected void done(List<MusicDirectory.Entry> songs) {
DownloadService downloadService = getDownloadService();