From 9d1b46b591c1bc28067229adaab92071fe59c6c9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 9 Nov 2019 16:44:13 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/audio/AudioPlayViewModel.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt index 0cfa4f042..101b71b31 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt @@ -9,6 +9,7 @@ import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp import io.legado.app.model.WebBook +import io.legado.app.service.AudioPlayService import io.legado.app.service.help.AudioPlay import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -17,12 +18,14 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) fun initData(intent: Intent) { execute { - AudioPlay.inBookshelf = intent.getBooleanExtra("inBookshelf", true) - val bookUrl = intent.getStringExtra("bookUrl") - AudioPlay.book = if (!bookUrl.isNullOrEmpty()) { - App.db.bookDao().getBook(bookUrl) - } else { - App.db.bookDao().lastReadBook + if (!AudioPlayService.isRun) { + AudioPlay.inBookshelf = intent.getBooleanExtra("inBookshelf", true) + val bookUrl = intent.getStringExtra("bookUrl") + AudioPlay.book = if (!bookUrl.isNullOrEmpty()) { + App.db.bookDao().getBook(bookUrl) + } else { + App.db.bookDao().lastReadBook + } } AudioPlay.book?.let { book -> AudioPlay.titleData.postValue(book.name)