|
|
|
@ -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,6 +18,7 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) |
|
|
|
|
|
|
|
|
|
fun initData(intent: Intent) { |
|
|
|
|
execute { |
|
|
|
|
if (!AudioPlayService.isRun) { |
|
|
|
|
AudioPlay.inBookshelf = intent.getBooleanExtra("inBookshelf", true) |
|
|
|
|
val bookUrl = intent.getStringExtra("bookUrl") |
|
|
|
|
AudioPlay.book = if (!bookUrl.isNullOrEmpty()) { |
|
|
|
@ -24,6 +26,7 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) |
|
|
|
|
} else { |
|
|
|
|
App.db.bookDao().lastReadBook |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
AudioPlay.book?.let { book -> |
|
|
|
|
AudioPlay.titleData.postValue(book.name) |
|
|
|
|
AudioPlay.coverData.postValue(book.getDisplayCover()) |
|
|
|
|