diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-01-05 14:21:07 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-01-05 14:21:07 +0100 |
commit | 3ba443a2d5d9acf1c3e2a3fde82d7b545795dd13 (patch) | |
tree | bf91d78df31d73c9ce97e0b9d627354204411cfd | |
parent | b676967a5fe70c746c1478de3bf8186de8ff89a4 (diff) | |
parent | bd217c8cf0a7d3db5f2126aa35ba8bfa41c6f7e3 (diff) | |
download | AntennaPod-3ba443a2d5d9acf1c3e2a3fde82d7b545795dd13.zip |
Merge pull request #1505 from mfietz/issue/1504-mediaplayer-npe
MediaPlayerActivity: Prevent onPrepareOptionsMenu NPE
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 45cc50d69..bfbf3d86f 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -1,7 +1,6 @@ package de.danoeh.antennapod.activity; import android.annotation.TargetApi; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -269,18 +268,23 @@ public abstract class MediaplayerActivity extends ActionBarActivity @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); + if(controller == null) { + return false; + } Playable media = controller.getMedia(); menu.findItem(R.id.support_item).setVisible( media != null && media.getPaymentLink() != null && (media instanceof FeedMedia) && + ((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getFlattrStatus().flattrable() ); boolean hasWebsiteLink = media != null && media.getWebsiteLink() != null; menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink); - boolean isItemAndHasLink = media != null && (media instanceof FeedMedia) && ((FeedMedia) media).getItem().getLink() != null; + boolean isItemAndHasLink = media != null && (media instanceof FeedMedia) && + ((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getLink() != null; menu.findItem(R.id.share_link_item).setVisible(isItemAndHasLink); menu.findItem(R.id.share_link_with_position_item).setVisible(isItemAndHasLink); @@ -291,15 +295,20 @@ public abstract class MediaplayerActivity extends ActionBarActivity menu.findItem(R.id.share_item).setVisible(hasWebsiteLink || isItemAndHasLink || isItemHasDownloadLink); menu.findItem(R.id.skip_episode_item).setVisible(media != null); + boolean sleepTimerSet = controller.sleepTimerActive(); boolean sleepTimerNotSet = controller.sleepTimerNotActive(); menu.findItem(R.id.set_sleeptimer_item).setVisible(sleepTimerNotSet); menu.findItem(R.id.disable_sleeptimer_item).setVisible(sleepTimerSet); + return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { + if(controller == null) { + return false; + } Playable media = controller.getMedia(); if (item.getItemId() == android.R.id.home) { Intent intent = new Intent(MediaplayerActivity.this, |