Revert "move adapter-selection logic into pickSongs()"

This breaks add-to-playlist from header menu

This reverts commit db5546cc6b585ac82e078d77c14d07e14964d73f.
This commit is contained in:
Adrian Ulrich 2016-06-01 22:14:54 +02:00
parent 4f868974c8
commit f8b4c763c2

View File

@ -373,11 +373,11 @@ public class LibraryActivity
private void pickSongs(Intent intent, int action) private void pickSongs(Intent intent, int action)
{ {
long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID); long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID);
int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID);
boolean all = false; boolean all = false;
int mode = action; int mode = action;
if (action == ACTION_PLAY_ALL || action == ACTION_ENQUEUE_ALL) { if (action == ACTION_PLAY_ALL || action == ACTION_ENQUEUE_ALL) {
int type = mCurrentAdapter.getMediaType();
boolean notPlayAllAdapter = type > MediaUtils.TYPE_SONG || id == LibraryAdapter.HEADER_ID; boolean notPlayAllAdapter = type > MediaUtils.TYPE_SONG || id == LibraryAdapter.HEADER_ID;
if (mode == ACTION_ENQUEUE_ALL && notPlayAllAdapter) { if (mode == ACTION_ENQUEUE_ALL && notPlayAllAdapter) {
mode = ACTION_ENQUEUE; mode = ACTION_ENQUEUE;
@ -387,8 +387,8 @@ public class LibraryActivity
all = true; all = true;
} }
} }
MediaAdapter adapterSource = (all || id == LibraryAdapter.HEADER_ID ? (MediaAdapter)mPagerAdapter.mAdapters[type] : null);
QueryTask query = buildQueryFromIntent(intent, false, adapterSource); QueryTask query = buildQueryFromIntent(intent, false, all);
query.mode = modeForAction[mode]; query.mode = modeForAction[mode];
PlaybackService.get(this).addSongs(query); PlaybackService.get(this).addSongs(query);
@ -593,9 +593,10 @@ public class LibraryActivity
* @param intent An intent created with * @param intent An intent created with
* {@link LibraryAdapter#createData(View)}. * {@link LibraryAdapter#createData(View)}.
* @param empty If true, use the empty projection (only query id). * @param empty If true, use the empty projection (only query id).
* @param adapterSource query all songs from this adapter if not null. * @param all If true query all songs in the adapter; otherwise query based
* on the row selected.
*/ */
private QueryTask buildQueryFromIntent(Intent intent, boolean empty, MediaAdapter adapterSource) private QueryTask buildQueryFromIntent(Intent intent, boolean empty, boolean all)
{ {
int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID); int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID);
@ -609,8 +610,8 @@ public class LibraryActivity
QueryTask query; QueryTask query;
if (type == MediaUtils.TYPE_FILE) { if (type == MediaUtils.TYPE_FILE) {
query = MediaUtils.buildFileQuery(intent.getStringExtra("file"), projection); query = MediaUtils.buildFileQuery(intent.getStringExtra("file"), projection);
} else if (adapterSource != null) { } else if (all || id == LibraryAdapter.HEADER_ID) {
query = adapterSource.buildSongQuery(projection); query = ((MediaAdapter)mPagerAdapter.mAdapters[type]).buildSongQuery(projection);
query.data = id; query.data = id;
} else { } else {
query = MediaUtils.buildQuery(type, id, projection, null); query = MediaUtils.buildQuery(type, id, projection, null);
@ -715,7 +716,7 @@ public class LibraryActivity
break; break;
case CTX_MENU_NEW_PLAYLIST: { case CTX_MENU_NEW_PLAYLIST: {
PlaylistTask playlistTask = new PlaylistTask(-1, null); PlaylistTask playlistTask = new PlaylistTask(-1, null);
playlistTask.query = buildQueryFromIntent(intent, true, null); playlistTask.query = buildQueryFromIntent(intent, true, false);
NewPlaylistDialog dialog = new NewPlaylistDialog(this, null, R.string.create, playlistTask); NewPlaylistDialog dialog = new NewPlaylistDialog(this, null, R.string.create, playlistTask);
dialog.setDismissMessage(mHandler.obtainMessage(MSG_NEW_PLAYLIST, dialog)); dialog.setDismissMessage(mHandler.obtainMessage(MSG_NEW_PLAYLIST, dialog));
dialog.show(); dialog.show();
@ -772,7 +773,7 @@ public class LibraryActivity
long playlistId = intent.getLongExtra("playlist", -1); long playlistId = intent.getLongExtra("playlist", -1);
String playlistName = intent.getStringExtra("playlistName"); String playlistName = intent.getStringExtra("playlistName");
PlaylistTask playlistTask = new PlaylistTask(playlistId, playlistName); PlaylistTask playlistTask = new PlaylistTask(playlistId, playlistName);
playlistTask.query = buildQueryFromIntent(intent, true, null); playlistTask.query = buildQueryFromIntent(intent, true, false);
mHandler.sendMessage(mHandler.obtainMessage(MSG_ADD_TO_PLAYLIST, playlistTask)); mHandler.sendMessage(mHandler.obtainMessage(MSG_ADD_TO_PLAYLIST, playlistTask));
break; break;
case CTX_MENU_MORE_FROM_ARTIST: { case CTX_MENU_MORE_FROM_ARTIST: {