修复阅读界面加入书架后,书籍详情页还是显示加入书架按钮的bug

pull/300/head
gedoor 4 years ago
parent 7a06e8e90a
commit 439997a1dc
  1. 3
      app/src/main/assets/updateLog.md
  2. 38
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -3,6 +3,9 @@
* 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
* 公众号会发布更新,请去公众号下载官方版本,防止软件包被篡改。 * 公众号会发布更新,请去公众号下载官方版本,防止软件包被篡改。
**2020/08/09**
* 修复阅读界面加入书架后,书籍详情页还是显示加入书架按钮的bug
**2020/08/08** **2020/08/08**
* 继续适配主题,现在应该所有地方都按照主题变色了 * 继续适配主题,现在应该所有地方都按照主题变色了
* 朗读定时增加到3个小时,朗读暂停恢复后继续定时 * 朗读定时增加到3个小时,朗读暂停恢复后继续定时

@ -55,6 +55,7 @@ class BookInfoActivity :
private val requestCodeChapterList = 568 private val requestCodeChapterList = 568
private val requestCodeSourceEdit = 562 private val requestCodeSourceEdit = 562
private val requestCodeRead = 432
override val viewModel: BookInfoViewModel override val viewModel: BookInfoViewModel
get() = getViewModel(BookInfoViewModel::class.java) get() = getViewModel(BookInfoViewModel::class.java)
@ -309,7 +310,8 @@ class BookInfoActivity :
Pair("bookUrl", book.bookUrl), Pair("bookUrl", book.bookUrl),
Pair("inBookshelf", viewModel.inBookshelf) Pair("inBookshelf", viewModel.inBookshelf)
) )
else -> startActivity<ReadBookActivity>( else -> startActivityForResult<ReadBookActivity>(
requestCodeRead,
Pair("bookUrl", book.bookUrl), Pair("bookUrl", book.bookUrl),
Pair("inBookshelf", viewModel.inBookshelf), Pair("inBookshelf", viewModel.inBookshelf),
Pair("key", IntentDataHelp.putData(book)) Pair("key", IntentDataHelp.putData(book))
@ -358,23 +360,29 @@ class BookInfoActivity :
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
when (requestCode) { when (requestCode) {
requestCodeSourceEdit -> if (resultCode == Activity.RESULT_OK) { requestCodeSourceEdit ->
viewModel.upEditBook() if (resultCode == Activity.RESULT_OK) {
} viewModel.upEditBook()
requestCodeChapterList -> if (resultCode == Activity.RESULT_OK) { }
viewModel.bookData.value?.let { requestCodeChapterList ->
data?.getIntExtra("index", it.durChapterIndex)?.let { index -> if (resultCode == Activity.RESULT_OK) {
if (it.durChapterIndex != index) { viewModel.bookData.value?.let {
it.durChapterIndex = index data?.getIntExtra("index", it.durChapterIndex)?.let { index ->
it.durChapterPos = 0 if (it.durChapterIndex != index) {
it.durChapterIndex = index
it.durChapterPos = 0
}
startReadActivity(it)
} }
startReadActivity(it) }
} else {
if (!viewModel.inBookshelf) {
viewModel.delBook()
} }
} }
} else { requestCodeRead -> if (resultCode == Activity.RESULT_OK) {
if (!viewModel.inBookshelf) { viewModel.inBookshelf = true
viewModel.delBook() upTvBookshelf()
}
} }
} }
} }

@ -740,7 +740,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
if (!ReadBook.inBookshelf) { if (!ReadBook.inBookshelf) {
this.alert(title = getString(R.string.add_to_shelf)) { this.alert(title = getString(R.string.add_to_shelf)) {
message = getString(R.string.check_add_bookshelf, it.name) 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() } } noButton { viewModel.removeFromBookshelf { super.finish() } }
}.show().applyTint() }.show().applyTint()
} else { } else {

Loading…
Cancel
Save