add "Empty queue" option in Queue activity

This commit is contained in:
Amin Bandali 2015-04-13 20:59:43 -04:00
parent 7feebb067f
commit 7b6fc6218a
5 changed files with 31 additions and 0 deletions

View File

@ -266,6 +266,7 @@ THE SOFTWARE.
<string name="enqueue_current_artist">Enqueue artist</string>
<string name="enqueue_current_genre">Enqueue genre</string>
<string name="clear_queue">Clear queue</string>
<string name="empty_the_queue">Empty queue</string>
<string name="show_queue">Show queue</string>
<string name="queue">Queue</string>
<string name="toggle_controls">Toggle controls</string>

View File

@ -349,6 +349,7 @@ public abstract class PlaybackActivity extends Activity
static final int MENU_SHOW_QUEUE = 13;
static final int MENU_SAVE_AS_PLAYLIST = 14;
static final int MENU_DELETE = 15;
static final int MENU_EMPTY_QUEUE = 16;
@Override
public boolean onCreateOptionsMenu(Menu menu)

View File

@ -1637,6 +1637,14 @@ public final class PlaybackService extends Service
mTimeline.clearQueue();
}
/**
* Empty the song queue.
*/
public void emptyQueue()
{
mTimeline.emptyQueue();
}
/**
* Return the error message set when FLAG_ERROR is set.
*/

View File

@ -73,6 +73,7 @@ public class ShowQueueActivity extends PlaybackActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_CLEAR_QUEUE, 0, R.string.clear_queue).setIcon(R.drawable.ic_menu_close_clear_cancel);
menu.add(0, MENU_EMPTY_QUEUE, 0, R.string.empty_the_queue);
menu.add(0, MENU_SAVE_AS_PLAYLIST, 0, R.string.save_as_playlist).setIcon(R.drawable.ic_menu_preferences);
return true;
}
@ -93,6 +94,9 @@ public class ShowQueueActivity extends PlaybackActivity
dialog.setOnDismissListener(this);
dialog.show();
break;
case MENU_EMPTY_QUEUE:
PlaybackService.get(this).emptyQueue();
break;
default:
return super.onOptionsItemSelected(item);
}

View File

@ -786,6 +786,23 @@ public final class SongTimeline {
changed();
}
/**
* Empty the song queue (clear the whole queue).
*/
public void emptyQueue()
{
synchronized (this) {
mSongs.clear();
}
if (mCallback != null) {
mCallback.activeSongReplaced(+1, getSong(+1));
mCallback.positionInfoChanged();
}
changed();
}
/**
* Save the active songs for use with broadcastChangedSongs().
*