pull/48/head
kunfei 5 years ago
parent fd80d18a52
commit 9d1b46b591
  1. 3
      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.data.entities.BookChapter
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import io.legado.app.service.AudioPlayService
import io.legado.app.service.help.AudioPlay import io.legado.app.service.help.AudioPlay
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -17,6 +18,7 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application)
fun initData(intent: Intent) { fun initData(intent: Intent) {
execute { execute {
if (!AudioPlayService.isRun) {
AudioPlay.inBookshelf = intent.getBooleanExtra("inBookshelf", true) AudioPlay.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
val bookUrl = intent.getStringExtra("bookUrl") val bookUrl = intent.getStringExtra("bookUrl")
AudioPlay.book = if (!bookUrl.isNullOrEmpty()) { AudioPlay.book = if (!bookUrl.isNullOrEmpty()) {
@ -24,6 +26,7 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application)
} else { } else {
App.db.bookDao().lastReadBook App.db.bookDao().lastReadBook
} }
}
AudioPlay.book?.let { book -> AudioPlay.book?.let { book ->
AudioPlay.titleData.postValue(book.name) AudioPlay.titleData.postValue(book.name)
AudioPlay.coverData.postValue(book.getDisplayCover()) AudioPlay.coverData.postValue(book.getDisplayCover())

Loading…
Cancel
Save