Prevent NPEs

This commit is contained in:
Martin Fietz 2016-06-24 12:15:00 +02:00
parent a2fc5a2b48
commit 9b13e19b66
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);
}