Fixed nullpointer exception when preparing menu

This commit is contained in:
daniel oeh 2012-07-16 11:09:43 +02:00
parent 4003ede4a7
commit ea67e94edb
1 changed files with 5 additions and 4 deletions

View File

@ -127,9 +127,10 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.support_item).setVisible(media.getItem().getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(media.getItem().getLink() != null);
menu.findItem(R.id.visit_website_item).setVisible(media.getItem().getLink() != null);
menu.findItem(R.id.support_item).setVisible(media != null && media.getItem().getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(media != null && media.getItem().getLink() != null);
menu.findItem(R.id.visit_website_item).setVisible(media != null && media.getItem().getLink() != null);
return true;
}
@ -498,7 +499,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
int requestedOrientation;
status = playbackService.getStatus();
media = playbackService.getMedia();
invalidateOptionsMenu();
registerReceiver(statusUpdate, new IntentFilter(
PlaybackService.ACTION_PLAYER_STATUS_CHANGED));