pull/32/head
kunfei 5 years ago
parent a214afd1cb
commit c10aefd3cd
  1. 13
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt

@ -106,7 +106,13 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
}
private fun showChapter(chapterList: List<BookChapter>) {
viewModel.bookData.value?.let {
if (it.durChapterIndex < chapterList.size) {
tv_current_chapter_info.text = chapterList[it.durChapterIndex].title
} else {
tv_current_chapter_info.text = chapterList.last().title
}
}
adapter.clearItems()
adapter.addItems(chapterList)
}
@ -157,6 +163,11 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
}
changeSourceDialog?.show(supportFragmentManager, ChangeSourceDialog.tag)
}
tv_current_chapter_info.onClick {
viewModel.bookData.value?.let {
rv_chapter_list.scrollToPosition(it.durChapterIndex)
}
}
}
override fun changeTo(book: Book) {

@ -62,10 +62,12 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
WebBook(bookSource).getChapterList(book)
.onSuccess(IO) {
it?.let {
if (inBookshelf) {
App.db.bookChapterDao().insert(*it.toTypedArray())
if (it.isNotEmpty()) {
if (inBookshelf) {
App.db.bookChapterDao().insert(*it.toTypedArray())
}
chapterListData.postValue(it)
}
chapterListData.postValue(it)
}
}.onError {
toast(R.string.error_get_chapter_list)

Loading…
Cancel
Save