move buildQueryFromIntent to SlidingPlaybackActivity
This commit is contained in:
parent
f8b4c763c2
commit
67160967ca
@ -388,7 +388,7 @@ public class LibraryActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryTask query = buildQueryFromIntent(intent, false, all);
|
QueryTask query = buildQueryFromIntent(intent, false, (all ? (MediaAdapter)mCurrentAdapter : null));
|
||||||
query.mode = modeForAction[mode];
|
query.mode = modeForAction[mode];
|
||||||
PlaybackService.get(this).addSongs(query);
|
PlaybackService.get(this).addSongs(query);
|
||||||
|
|
||||||
@ -593,31 +593,16 @@ 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 all If true query all songs in the adapter; otherwise query based
|
* @param allSource use this mediaAdapter to queue all hold items
|
||||||
* on the row selected.
|
|
||||||
*/
|
*/
|
||||||
private QueryTask buildQueryFromIntent(Intent intent, boolean empty, boolean all)
|
@Override
|
||||||
{
|
protected QueryTask buildQueryFromIntent(Intent intent, boolean empty, MediaAdapter allSource) {
|
||||||
int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID);
|
|
||||||
|
|
||||||
String[] projection;
|
|
||||||
if (type == MediaUtils.TYPE_PLAYLIST)
|
|
||||||
projection = empty ? Song.EMPTY_PLAYLIST_PROJECTION : Song.FILLED_PLAYLIST_PROJECTION;
|
|
||||||
else
|
|
||||||
projection = empty ? Song.EMPTY_PROJECTION : Song.FILLED_PROJECTION;
|
|
||||||
|
|
||||||
long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID);
|
long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID);
|
||||||
QueryTask query;
|
if (allSource == null && id == LibraryAdapter.HEADER_ID) {
|
||||||
if (type == MediaUtils.TYPE_FILE) {
|
// 'all' was not forced, but user clicked on the header: use the current adapter
|
||||||
query = MediaUtils.buildFileQuery(intent.getStringExtra("file"), projection);
|
allSource = (MediaAdapter)mCurrentAdapter;
|
||||||
} else if (all || id == LibraryAdapter.HEADER_ID) {
|
|
||||||
query = ((MediaAdapter)mPagerAdapter.mAdapters[type]).buildSongQuery(projection);
|
|
||||||
query.data = id;
|
|
||||||
} else {
|
|
||||||
query = MediaUtils.buildQuery(type, id, projection, null);
|
|
||||||
}
|
}
|
||||||
|
return super.buildQueryFromIntent(intent, empty, allSource);
|
||||||
return query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int CTX_MENU_PLAY = 0;
|
private static final int CTX_MENU_PLAY = 0;
|
||||||
@ -716,7 +701,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, false);
|
playlistTask.query = buildQueryFromIntent(intent, true, null);
|
||||||
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();
|
||||||
@ -773,7 +758,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, false);
|
playlistTask.query = buildQueryFromIntent(intent, true, null);
|
||||||
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: {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package ch.blinkenlights.android.vanilla;
|
package ch.blinkenlights.android.vanilla;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -164,6 +165,38 @@ public class SlidingPlaybackActivity extends PlaybackActivity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a media query based off the data stored in the given intent.
|
||||||
|
*
|
||||||
|
* @param intent An intent created with
|
||||||
|
* {@link LibraryAdapter#createData(View)}.
|
||||||
|
* @param empty If true, use the empty projection (only query id).
|
||||||
|
* @param allSource use this mediaAdapter to queue all hold items
|
||||||
|
*/
|
||||||
|
protected QueryTask buildQueryFromIntent(Intent intent, boolean empty, MediaAdapter allSource)
|
||||||
|
{
|
||||||
|
int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID);
|
||||||
|
|
||||||
|
String[] projection;
|
||||||
|
if (type == MediaUtils.TYPE_PLAYLIST)
|
||||||
|
projection = empty ? Song.EMPTY_PLAYLIST_PROJECTION : Song.FILLED_PLAYLIST_PROJECTION;
|
||||||
|
else
|
||||||
|
projection = empty ? Song.EMPTY_PROJECTION : Song.FILLED_PROJECTION;
|
||||||
|
|
||||||
|
long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID);
|
||||||
|
QueryTask query;
|
||||||
|
if (type == MediaUtils.TYPE_FILE) {
|
||||||
|
query = MediaUtils.buildFileQuery(intent.getStringExtra("file"), projection);
|
||||||
|
} else if (allSource != null) {
|
||||||
|
query = allSource.buildSongQuery(projection);
|
||||||
|
query.data = id;
|
||||||
|
} else {
|
||||||
|
query = MediaUtils.buildQuery(type, id, projection, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the current song duration fields.
|
* Update the current song duration fields.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user