From 381c145930a7021213d61d27f91a6106dbad6c38 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Jun 2018 20:32:56 +0200 Subject: [PATCH] add a musicPlayer null check at updating the UI --- .../musicplayer/services/MusicService.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt index 3845603c..b4146c45 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt @@ -245,12 +245,14 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr private fun updateUI() { Handler(Looper.getMainLooper()).post { - mBus!!.post(Events.PlaylistUpdated(mSongs)) - mCurrSongCover = getAlbumImage(mCurrSong) - mBus!!.post(Events.SongChanged(mCurrSong)) + if (mPlayer != null) { + mBus!!.post(Events.PlaylistUpdated(mSongs)) + mCurrSongCover = getAlbumImage(mCurrSong) + mBus!!.post(Events.SongChanged(mCurrSong)) - val secs = mPlayer!!.currentPosition / 1000 - mBus!!.post(Events.ProgressUpdated(secs)) + val secs = mPlayer!!.currentPosition / 1000 + mBus!!.post(Events.ProgressUpdated(secs)) + } } songStateChanged(getIsPlaying()) }