From c8d0109008424d1a76febd30d1fb25ebe75df265 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 25 Jan 2020 11:56:03 +0800 Subject: [PATCH] up --- .../app/ui/book/info/BookInfoActivity.kt | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) 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 {} + } } } }