Merge pull request #160 from aminb/empty-queue
add "Empty queue" option in Queue activity
This commit is contained in:
commit
c02b77cafe
@ -266,6 +266,7 @@ THE SOFTWARE.
|
|||||||
<string name="enqueue_current_artist">Enqueue artist</string>
|
<string name="enqueue_current_artist">Enqueue artist</string>
|
||||||
<string name="enqueue_current_genre">Enqueue genre</string>
|
<string name="enqueue_current_genre">Enqueue genre</string>
|
||||||
<string name="clear_queue">Clear queue</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="show_queue">Show queue</string>
|
||||||
<string name="queue">Queue</string>
|
<string name="queue">Queue</string>
|
||||||
<string name="toggle_controls">Toggle controls</string>
|
<string name="toggle_controls">Toggle controls</string>
|
||||||
|
@ -349,6 +349,7 @@ public abstract class PlaybackActivity extends Activity
|
|||||||
static final int MENU_SHOW_QUEUE = 13;
|
static final int MENU_SHOW_QUEUE = 13;
|
||||||
static final int MENU_SAVE_AS_PLAYLIST = 14;
|
static final int MENU_SAVE_AS_PLAYLIST = 14;
|
||||||
static final int MENU_DELETE = 15;
|
static final int MENU_DELETE = 15;
|
||||||
|
static final int MENU_EMPTY_QUEUE = 16;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu)
|
public boolean onCreateOptionsMenu(Menu menu)
|
||||||
|
@ -1637,6 +1637,16 @@ public final class PlaybackService extends Service
|
|||||||
mTimeline.clearQueue();
|
mTimeline.clearQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty the song queue.
|
||||||
|
*/
|
||||||
|
public void emptyQueue()
|
||||||
|
{
|
||||||
|
pause();
|
||||||
|
setFlag(FLAG_EMPTY_QUEUE);
|
||||||
|
mTimeline.emptyQueue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the error message set when FLAG_ERROR is set.
|
* Return the error message set when FLAG_ERROR is set.
|
||||||
*/
|
*/
|
||||||
|
@ -73,6 +73,7 @@ public class ShowQueueActivity extends PlaybackActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
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_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);
|
menu.add(0, MENU_SAVE_AS_PLAYLIST, 0, R.string.save_as_playlist).setIcon(R.drawable.ic_menu_preferences);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,6 +94,9 @@ public class ShowQueueActivity extends PlaybackActivity
|
|||||||
dialog.setOnDismissListener(this);
|
dialog.setOnDismissListener(this);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
break;
|
break;
|
||||||
|
case MENU_EMPTY_QUEUE:
|
||||||
|
PlaybackService.get(this).emptyQueue();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -774,15 +774,26 @@ public final class SongTimeline {
|
|||||||
public void clearQueue()
|
public void clearQueue()
|
||||||
{
|
{
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
saveActiveSongs();
|
||||||
if (mCurrentPos + 1 < mSongs.size())
|
if (mCurrentPos + 1 < mSongs.size())
|
||||||
mSongs.subList(mCurrentPos + 1, mSongs.size()).clear();
|
mSongs.subList(mCurrentPos + 1, mSongs.size()).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCallback != null) {
|
broadcastChangedSongs();
|
||||||
mCallback.activeSongReplaced(+1, getSong(+1));
|
changed();
|
||||||
mCallback.positionInfoChanged();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty the song queue (clear the whole queue).
|
||||||
|
*/
|
||||||
|
public void emptyQueue()
|
||||||
|
{
|
||||||
|
synchronized (this) {
|
||||||
|
saveActiveSongs();
|
||||||
|
mSongs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
broadcastChangedSongs();
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user