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 e637d3eb5..117440ad7 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 @@ -217,14 +217,11 @@ class BookInfoActivity : } tv_toc.onClick { if (!viewModel.inBookshelf) { - toast(R.string.after_add_bookshelf) - return@onClick - } - viewModel.bookData.value?.let { - startActivityForResult( - requestCodeChapterList, - Pair("bookUrl", it.bookUrl) - ) + viewModel.saveBook { + openChapterList() + } + } else { + openChapterList() } } tv_group.onClick { @@ -232,6 +229,15 @@ class BookInfoActivity : } } + private fun openChapterList() { + viewModel.bookData.value?.let { + startActivityForResult( + requestCodeChapterList, + Pair("bookUrl", it.bookUrl) + ) + } + } + private fun readBook(book: Book) { if (!viewModel.inBookshelf) { viewModel.saveBook { @@ -306,6 +312,10 @@ class BookInfoActivity : readBook(it) } } + } else { + if (!viewModel.inBookshelf) { + viewModel.delBook {} + } } } }