check return value of getSong(0)

This commit is contained in:
Adrian Ulrich 2015-01-01 08:53:18 +01:00
parent 0832a0175d
commit 84f153d49a

View File

@ -402,24 +402,27 @@ public class FullPlaybackActivity extends PlaybackActivity
final PlaybackService playbackService = PlaybackService.get(this); final PlaybackService playbackService = PlaybackService.get(this);
final Song sng = playbackService.getSong(0); final Song sng = playbackService.getSong(0);
final PlaybackActivity activity = this; final PlaybackActivity activity = this;
String delete_message = getString(R.string.delete_item, sng.title);
AlertDialog.Builder dialog = new AlertDialog.Builder(this); if (sng != null) {
dialog.setTitle(R.string.delete); String delete_message = getString(R.string.delete_item, sng.title);
dialog AlertDialog.Builder dialog = new AlertDialog.Builder(this);
.setMessage(delete_message) dialog.setTitle(R.string.delete);
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { dialog
public void onClick(DialogInterface dialog, int id) { .setMessage(delete_message)
shiftCurrentSong(SongTimeline.SHIFT_NEXT_SONG); .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
int count = playbackService.deleteMedia(MediaUtils.TYPE_SONG, sng.id); public void onClick(DialogInterface dialog, int id) {
String msg = getResources().getQuantityString(R.plurals.deleted, count, count); shiftCurrentSong(SongTimeline.SHIFT_NEXT_SONG);
Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show(); int count = playbackService.deleteMedia(MediaUtils.TYPE_SONG, sng.id);
} String msg = getResources().getQuantityString(R.plurals.deleted, count, count);
}) Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { }
public void onClick(DialogInterface dialog, int id) { })
} .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
}); public void onClick(DialogInterface dialog, int id) {
}
});
dialog.create().show(); dialog.create().show();
}
break; break;
case MENU_SHOW_QUEUE: case MENU_SHOW_QUEUE:
startActivity(new Intent(this, ShowQueueActivity.class)); startActivity(new Intent(this, ShowQueueActivity.class));