diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 9cf8fa8f5..18872071e 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -300,9 +300,7 @@ class BookInfoActivity : } } tvChangeSource.setOnClickListener { - viewModel.bookData.value?.let { - showDialogFragment(ChangeBookSourceDialog(it.name, it.author)) - } + showDialogFragment(ChangeBookSourceDialog(viewModel.name, viewModel.author)) } tvTocView.setOnClickListener { if (!viewModel.inBookshelf) { diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index 0fcfb9ee9..35069c8ec 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -27,6 +27,8 @@ import kotlinx.coroutines.Dispatchers.IO class BookInfoViewModel(application: Application) : BaseViewModel(application) { val bookData = MutableLiveData() val chapterListData = MutableLiveData>() + var name = "" + var author = "" var durChapterIndex = 0 var inBookshelf = false var bookSource: BookSource? = null @@ -34,8 +36,8 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { fun initData(intent: Intent) { execute { - val name = intent.getStringExtra("name") ?: "" - val author = intent.getStringExtra("author") ?: "" + name = intent.getStringExtra("name") ?: "" + author = intent.getStringExtra("author") ?: "" val bookUrl = intent.getStringExtra("bookUrl") ?: "" appDb.bookDao.getBook(name, author)?.let { inBookshelf = true