From 14cf2e53310964fa592015033c076cd5608d9bce Mon Sep 17 00:00:00 2001 From: Paul Woitaschek Date: Sat, 5 Jan 2019 22:47:45 +0100 Subject: [PATCH] Check if we are still attached upon seekbar change. --- .../ph1b/audiobook/features/bookPlaying/BookPlayController.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/ph1b/audiobook/features/bookPlaying/BookPlayController.kt b/app/src/main/java/de/ph1b/audiobook/features/bookPlaying/BookPlayController.kt index f9490da241..1debfd4a06 100644 --- a/app/src/main/java/de/ph1b/audiobook/features/bookPlaying/BookPlayController.kt +++ b/app/src/main/java/de/ph1b/audiobook/features/bookPlaying/BookPlayController.kt @@ -172,7 +172,8 @@ class BookPlayController( private fun setupSeekBar() { seekBar.setOnSeekBarChangeListener( object : SeekBar.OnSeekBarChangeListener { - override fun onProgressChanged(view: SeekBar?, progress: Int, p2: Boolean) { + override fun onProgressChanged(view: SeekBar?, progress: Int, fromUser: Boolean) { + if (!isAttached) return // sets text to adjust while using seekBar playedTime.text = formatTime(progress.toLong(), seekBar.max.toLong()) } @@ -181,6 +182,7 @@ class BookPlayController( } override fun onStopTrackingTouch(view: SeekBar?) { + if (!isAttached) return currentChapter?.let { val progress = seekBar.progress presenter.seekTo(it.start + progress, it.file)