feat: 修复从发现界面打开已在书架的书时,显示不对的问题

pull/238/head
gedoor 5 years ago
parent a1d6179ee9
commit 1987adc266
  1. 3
      app/src/main/assets/updateLog.md
  2. 3
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  5. 8
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  6. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt

@ -3,6 +3,9 @@
* 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
* 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用
**2020/06/09**
* 修复从发现界面打开已在书架的书时,显示不对的问题
**2020/06/07** **2020/06/07**
* 优化书源检测,自定义搜索关键词 * 优化书源检测,自定义搜索关键词
* 失效书源如果校验为有效会去掉失效标志 * 失效书源如果校验为有效会去掉失效标志

@ -72,7 +72,8 @@ class ExploreShowActivity : VMBaseActivity<ExploreShowViewModel>(R.layout.activi
override fun showBookInfo(book: Book) { override fun showBookInfo(book: Book) {
startActivity<BookInfoActivity>( startActivity<BookInfoActivity>(
Pair("bookUrl", book.bookUrl) Pair("name", book.name),
Pair("author", book.author)
) )
} }
} }

@ -22,16 +22,16 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
fun initData(intent: Intent) { fun initData(intent: Intent) {
execute { execute {
intent.getStringExtra("bookUrl")?.let { val name = intent.getStringExtra("name") ?: ""
App.db.bookDao().getBook(it)?.let { book -> val author = intent.getStringExtra("author") ?: ""
App.db.bookDao().getBook(name, author)?.let { book ->
inBookshelf = true inBookshelf = true
setBook(book) setBook(book)
} ?: App.db.searchBookDao().getSearchBook(it)?.toBook()?.let { book -> } ?: App.db.searchBookDao().getFirstByNameAuthor(name, author)?.toBook()?.let { book ->
setBook(book) setBook(book)
} }
} }
} }
}
private fun setBook(book: Book) { private fun setBook(book: Book) {
durChapterIndex = book.durChapterIndex durChapterIndex = book.durChapterIndex

@ -242,7 +242,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
onReplaceRuleSave() onReplaceRuleSave()
} }
R.id.menu_book_info -> ReadBook.book?.let { R.id.menu_book_info -> ReadBook.book?.let {
startActivity<BookInfoActivity>(Pair("bookUrl", it.bookUrl)) startActivity<BookInfoActivity>(
Pair("name", it.name),
Pair("author", it.author)
)
} }
R.id.menu_toc_regex -> TocRegexDialog.show( R.id.menu_toc_regex -> TocRegexDialog.show(
supportFragmentManager, supportFragmentManager,

@ -317,7 +317,10 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
override fun showBookInfo(name: String, author: String) { override fun showBookInfo(name: String, author: String) {
viewModel.getSearchBook(name, author) { searchBook -> viewModel.getSearchBook(name, author) { searchBook ->
searchBook?.let { searchBook?.let {
startActivity<BookInfoActivity>(Pair("bookUrl", it.bookUrl)) startActivity<BookInfoActivity>(
Pair("name", it.name),
Pair("author", it.author)
)
} }
} }
} }
@ -327,7 +330,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
*/ */
override fun showBookInfo(book: Book) { override fun showBookInfo(book: Book) {
startActivity<BookInfoActivity>( startActivity<BookInfoActivity>(
Pair("bookUrl", book.bookUrl) Pair("name", book.name),
Pair("author", book.author)
) )
} }

@ -111,7 +111,10 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
} }
override fun openBookInfo(book: Book) { override fun openBookInfo(book: Book) {
context?.startActivity<BookInfoActivity>(Pair("bookUrl", book.bookUrl)) context?.startActivity<BookInfoActivity>(
Pair("name", book.name),
Pair("author", book.author)
)
} }
override fun isUpdate(bookUrl: String): Boolean { override fun isUpdate(bookUrl: String): Boolean {

Loading…
Cancel
Save