From 439997a1dcba17f45b17b84a9727ece99fbe12fa Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 9 Aug 2020 09:41:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=85=E8=AF=BB=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8A=A0=E5=85=A5=E4=B9=A6=E6=9E=B6=E5=90=8E,?= =?UTF-8?q?=E4=B9=A6=E7=B1=8D=E8=AF=A6=E6=83=85=E9=A1=B5=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=A0=E5=85=A5=E4=B9=A6=E6=9E=B6=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 ++ .../app/ui/book/info/BookInfoActivity.kt | 38 +++++++++++-------- .../app/ui/book/read/ReadBookActivity.kt | 5 ++- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 0a12daeff..579b64e04 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 公众号会发布更新,请去公众号下载官方版本,防止软件包被篡改。 +**2020/08/09** +* 修复阅读界面加入书架后,书籍详情页还是显示加入书架按钮的bug + **2020/08/08** * 继续适配主题,现在应该所有地方都按照主题变色了 * 朗读定时增加到3个小时,朗读暂停恢复后继续定时 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 532575449..e94dab3b8 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 @@ -55,6 +55,7 @@ class BookInfoActivity : private val requestCodeChapterList = 568 private val requestCodeSourceEdit = 562 + private val requestCodeRead = 432 override val viewModel: BookInfoViewModel get() = getViewModel(BookInfoViewModel::class.java) @@ -309,7 +310,8 @@ class BookInfoActivity : Pair("bookUrl", book.bookUrl), Pair("inBookshelf", viewModel.inBookshelf) ) - else -> startActivity( + else -> startActivityForResult( + requestCodeRead, Pair("bookUrl", book.bookUrl), Pair("inBookshelf", viewModel.inBookshelf), Pair("key", IntentDataHelp.putData(book)) @@ -358,23 +360,29 @@ class BookInfoActivity : override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { - requestCodeSourceEdit -> if (resultCode == Activity.RESULT_OK) { - viewModel.upEditBook() - } - requestCodeChapterList -> if (resultCode == Activity.RESULT_OK) { - viewModel.bookData.value?.let { - data?.getIntExtra("index", it.durChapterIndex)?.let { index -> - if (it.durChapterIndex != index) { - it.durChapterIndex = index - it.durChapterPos = 0 + requestCodeSourceEdit -> + if (resultCode == Activity.RESULT_OK) { + viewModel.upEditBook() + } + requestCodeChapterList -> + if (resultCode == Activity.RESULT_OK) { + viewModel.bookData.value?.let { + data?.getIntExtra("index", it.durChapterIndex)?.let { index -> + if (it.durChapterIndex != index) { + it.durChapterIndex = index + it.durChapterPos = 0 + } + startReadActivity(it) } - startReadActivity(it) + } + } else { + if (!viewModel.inBookshelf) { + viewModel.delBook() } } - } else { - if (!viewModel.inBookshelf) { - viewModel.delBook() - } + requestCodeRead -> if (resultCode == Activity.RESULT_OK) { + viewModel.inBookshelf = true + upTvBookshelf() } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 38bd04b42..461f7598b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -740,7 +740,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo if (!ReadBook.inBookshelf) { this.alert(title = getString(R.string.add_to_shelf)) { message = getString(R.string.check_add_bookshelf, it.name) - okButton { ReadBook.inBookshelf = true } + okButton { + ReadBook.inBookshelf = true + setResult(Activity.RESULT_OK) + } noButton { viewModel.removeFromBookshelf { super.finish() } } }.show().applyTint() } else {