Handle repeat/shuffle toasts in PlaybackService

Prevents toasts from being shown multiple times..
This commit is contained in:
Christopher Eby 2010-06-02 22:33:53 -05:00
parent ae27040cd4
commit 5f53a5dbc2
2 changed files with 15 additions and 13 deletions

View File

@ -29,7 +29,6 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
public class PlaybackActivity extends Activity implements Handler.Callback, View.OnClickListener {
Handler mHandler;
@ -126,18 +125,8 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
if (mState == state)
return;
int oldState = mState;
mState = state;
if ((oldState & PlaybackService.FLAG_SHUFFLE) == 0 && (state & PlaybackService.FLAG_SHUFFLE) != 0)
Toast.makeText(this, R.string.shuffle_enabling, Toast.LENGTH_LONG).show();
else if ((oldState & PlaybackService.FLAG_SHUFFLE) != 0 && (state & PlaybackService.FLAG_SHUFFLE) == 0)
Toast.makeText(this, R.string.shuffle_disabling, Toast.LENGTH_SHORT).show();
if ((oldState & PlaybackService.FLAG_REPEAT) == 0 && (state & PlaybackService.FLAG_REPEAT) != 0)
Toast.makeText(this, R.string.repeat_enabling, Toast.LENGTH_LONG).show();
else if ((oldState & PlaybackService.FLAG_REPEAT) != 0 && (state & PlaybackService.FLAG_REPEAT) == 0)
Toast.makeText(this, R.string.repeat_disabling, Toast.LENGTH_SHORT).show();
if (mPlayPauseButton != null) {
final int res = (mState & PlaybackService.FLAG_PLAYING) == 0 ? R.drawable.play : R.drawable.pause;
runOnUiThread(new Runnable() {

View File

@ -476,8 +476,21 @@ public final class PlaybackService extends Service implements Handler.Callback,
mLastSongBroadcast = song;
}
mTimeline.setRepeat((state & FLAG_REPEAT) != 0);
mTimeline.setShuffle((state & FLAG_SHUFFLE) != 0);
if ((oldState & PlaybackService.FLAG_SHUFFLE) == 0 && (state & PlaybackService.FLAG_SHUFFLE) != 0) {
mTimeline.setShuffle(true);
Toast.makeText(this, R.string.shuffle_enabling, Toast.LENGTH_LONG).show();
} else if ((oldState & PlaybackService.FLAG_SHUFFLE) != 0 && (state & PlaybackService.FLAG_SHUFFLE) == 0) {
mTimeline.setShuffle(false);
Toast.makeText(this, R.string.shuffle_disabling, Toast.LENGTH_SHORT).show();
}
if ((oldState & PlaybackService.FLAG_REPEAT) == 0 && (state & PlaybackService.FLAG_REPEAT) != 0) {
mTimeline.setRepeat(true);
Toast.makeText(this, R.string.repeat_enabling, Toast.LENGTH_LONG).show();
} else if ((oldState & PlaybackService.FLAG_REPEAT) != 0 && (state & PlaybackService.FLAG_REPEAT) == 0) {
mTimeline.setRepeat(false);
Toast.makeText(this, R.string.repeat_disabling, Toast.LENGTH_SHORT).show();
}
if ((state & FLAG_NO_MEDIA) != 0 && (oldState & FLAG_NO_MEDIA) == 0) {
ContentResolver resolver = ContextApplication.getContext().getContentResolver();