From 7b400995c92027718b3b50d54098a7b7eacda691 Mon Sep 17 00:00:00 2001 From: Florian Friemel Date: Wed, 28 Sep 2016 18:12:51 +0200 Subject: [PATCH] Fix NullPointerException in PreviewMediaFragment. Added null-checks for mVideoPreview and mMediaServiceBinder. Resolves: #252 --- .../ui/preview/PreviewMediaFragment.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 9bebba1dc5..680cd8583c 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -248,17 +248,21 @@ public class PreviewMediaFragment extends FileFragment implements outState.putParcelable(PreviewMediaFragment.EXTRA_ACCOUNT, mAccount); if (getFile().isVideo()) { - mSavedPlaybackPosition = mVideoPreview.getCurrentPosition(); - mAutoplay = mVideoPreview.isPlaying(); - outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION, mSavedPlaybackPosition); - outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING, mAutoplay); + if (mVideoPreview != null) { + mSavedPlaybackPosition = mVideoPreview.getCurrentPosition(); + mAutoplay = mVideoPreview.isPlaying(); + outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION, mSavedPlaybackPosition); + outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING, mAutoplay); + } } else { - outState.putInt( - PreviewMediaFragment.EXTRA_PLAY_POSITION, - mMediaServiceBinder.getCurrentPosition()); - outState.putBoolean( - PreviewMediaFragment.EXTRA_PLAYING, mMediaServiceBinder.isPlaying()); + if (mMediaServiceBinder != null) { + outState.putInt( + PreviewMediaFragment.EXTRA_PLAY_POSITION, + mMediaServiceBinder.getCurrentPosition()); + outState.putBoolean( + PreviewMediaFragment.EXTRA_PLAYING, mMediaServiceBinder.isPlaying()); + } } }