Fixed possible nullpointerexception in onPositionObserverUpdate()

This commit is contained in:
daniel oeh 2012-09-26 21:21:04 +02:00
parent 258a6acd6e
commit 891f2e09f4
1 changed files with 15 additions and 12 deletions

View File

@ -317,10 +317,12 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
protected abstract void clearStatusMsg(); protected abstract void clearStatusMsg();
protected void onPositionObserverUpdate() { protected void onPositionObserverUpdate() {
if (controller != null) {
int currentPosition = controller.getPosition(); int currentPosition = controller.getPosition();
int duration = controller.getDuration(); int duration = controller.getDuration();
if (currentPosition != PlaybackService.INVALID_TIME if (currentPosition != PlaybackService.INVALID_TIME
&& duration != PlaybackService.INVALID_TIME) { && duration != PlaybackService.INVALID_TIME
&& controller.getMedia() != null) {
controller.getMedia().setPosition(currentPosition); controller.getMedia().setPosition(currentPosition);
txtvPosition.setText(Converter txtvPosition.setText(Converter
.getDurationStringLong(currentPosition)); .getDurationStringLong(currentPosition));
@ -331,6 +333,7 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
"Could not react to position observer update because of invalid time"); "Could not react to position observer update because of invalid time");
} }
} }
}
private void updateProgressbarPosition(int position, int duration) { private void updateProgressbarPosition(int position, int duration) {
if (AppConfig.DEBUG) if (AppConfig.DEBUG)