Merge pull request #2044 from mfietz/issue/2043-mediaplayeract-npe

MediaplayerActivity & MediaplayerInfoActivity: Prevent NPEs
This commit is contained in:
Martin Fietz 2016-06-24 12:14:27 +02:00 committed by GitHub
commit d5e63cb52c
2 changed files with 8 additions and 9 deletions

View File

@ -630,17 +630,16 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
*/
protected boolean loadMediaInfo() {
Log.d(TAG, "loadMediaInfo()");
if(controller == null || controller.getMedia() == null) {
return false;
}
Playable media = controller.getMedia();
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
showTimeLeft = prefs.getBoolean(PREF_SHOW_TIME_LEFT, false);
if (media != null) {
onPositionObserverUpdate();
checkFavorite();
updatePlaybackSpeedButton();
return true;
} else {
return false;
}
onPositionObserverUpdate();
checkFavorite();
updatePlaybackSpeedButton();
return true;
}
protected void updatePlaybackSpeedButton() {

View File

@ -277,7 +277,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
if (!super.loadMediaInfo()) {
return false;
}
if(controller.getMedia() != media) {
if(controller != null && controller.getMedia() != media) {
media = controller.getMedia();
pagerAdapter.onMediaChanged(media);
}