优化
This commit is contained in:
@@ -300,9 +300,7 @@ class BookInfoActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tvChangeSource.setOnClickListener {
|
tvChangeSource.setOnClickListener {
|
||||||
viewModel.bookData.value?.let {
|
showDialogFragment(ChangeBookSourceDialog(viewModel.name, viewModel.author))
|
||||||
showDialogFragment(ChangeBookSourceDialog(it.name, it.author))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tvTocView.setOnClickListener {
|
tvTocView.setOnClickListener {
|
||||||
if (!viewModel.inBookshelf) {
|
if (!viewModel.inBookshelf) {
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import kotlinx.coroutines.Dispatchers.IO
|
|||||||
class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
||||||
val bookData = MutableLiveData<Book>()
|
val bookData = MutableLiveData<Book>()
|
||||||
val chapterListData = MutableLiveData<List<BookChapter>>()
|
val chapterListData = MutableLiveData<List<BookChapter>>()
|
||||||
|
var name = ""
|
||||||
|
var author = ""
|
||||||
var durChapterIndex = 0
|
var durChapterIndex = 0
|
||||||
var inBookshelf = false
|
var inBookshelf = false
|
||||||
var bookSource: BookSource? = null
|
var bookSource: BookSource? = null
|
||||||
@@ -34,8 +36,8 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
|
|
||||||
fun initData(intent: Intent) {
|
fun initData(intent: Intent) {
|
||||||
execute {
|
execute {
|
||||||
val name = intent.getStringExtra("name") ?: ""
|
name = intent.getStringExtra("name") ?: ""
|
||||||
val author = intent.getStringExtra("author") ?: ""
|
author = intent.getStringExtra("author") ?: ""
|
||||||
val bookUrl = intent.getStringExtra("bookUrl") ?: ""
|
val bookUrl = intent.getStringExtra("bookUrl") ?: ""
|
||||||
appDb.bookDao.getBook(name, author)?.let {
|
appDb.bookDao.getBook(name, author)?.let {
|
||||||
inBookshelf = true
|
inBookshelf = true
|
||||||
|
|||||||
Reference in New Issue
Block a user