pull/90/head^2
kunfei 5 years ago
parent fec631fecf
commit 705c38cd09
  1. 27
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
  2. 10
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt

@ -51,17 +51,17 @@ object BookChapterList {
ruleUrl = nextUrl, book = book, headerMapF = bookSource.getHeaderMap() ruleUrl = nextUrl, book = book, headerMapF = bookSource.getHeaderMap()
).getResponseAwait() ).getResponseAwait()
.body?.let { nextBody -> .body?.let { nextBody ->
chapterData = analyzeChapterList( chapterData = analyzeChapterList(
nextBody, nextUrl, tocRule, listRule, nextBody, nextUrl, tocRule, listRule,
book, bookSource, log = false book, bookSource, log = false
) )
nextUrl = if (chapterData.nextUrl.isNotEmpty()) nextUrl = if (chapterData.nextUrl.isNotEmpty())
chapterData.nextUrl[0] chapterData.nextUrl[0]
else "" else ""
chapterData.chapterList?.let { chapterData.chapterList?.let {
chapterList.addAll(it) chapterList.addAll(it)
}
} }
}
} }
Debug.log(bookSource.bookSourceUrl, "◇目录总页数:${nextUrlList.size}") Debug.log(bookSource.bookSourceUrl, "◇目录总页数:${nextUrlList.size}")
} else if (chapterData.nextUrl.size > 1) { } else if (chapterData.nextUrl.size > 1) {
@ -100,11 +100,8 @@ object BookChapterList {
item.index = index item.index = index
} }
book.latestChapterTitle = chapterList.last().title book.latestChapterTitle = chapterList.last().title
if (book.durChapterIndex < chapterList.size) { book.durChapterTitle =
book.durChapterTitle = chapterList[book.durChapterIndex].title chapterList.getOrNull(book.durChapterIndex)?.title ?: book.latestChapterTitle
} else {
book.durChapterTitle = book.latestChapterTitle
}
if (book.totalChapterNum < chapterList.size) { if (book.totalChapterNum < chapterList.size) {
book.lastCheckCount = chapterList.size - book.totalChapterNum book.lastCheckCount = chapterList.size - book.totalChapterNum
} }

@ -20,8 +20,9 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
ArrangeBookAdapter.CallBack { ArrangeBookAdapter.CallBack {
override val viewModel: ArrangeBookViewModel override val viewModel: ArrangeBookViewModel
get() = getViewModel(ArrangeBookViewModel::class.java) get() = getViewModel(ArrangeBookViewModel::class.java)
override val groupList: List<BookGroup> = arrayListOf() override val groupList: ArrayList<BookGroup> = arrayListOf()
private lateinit var adapter: ArrangeBookAdapter private lateinit var adapter: ArrangeBookAdapter
private var groupLiveData: LiveData<List<BookGroup>>? = null
private var booksLiveData: LiveData<List<Book>>? = null private var booksLiveData: LiveData<List<Book>>? = null
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
@ -49,6 +50,13 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
} }
private fun initData() { private fun initData() {
groupLiveData?.removeObservers(this)
groupLiveData = App.db.bookGroupDao().liveDataAll()
groupLiveData?.observe(this, Observer {
groupList.clear()
groupList.addAll(it)
adapter.notifyDataSetChanged()
})
booksLiveData?.removeObservers(this) booksLiveData?.removeObservers(this)
booksLiveData = App.db.bookDao().observeAll() booksLiveData = App.db.bookDao().observeAll()
booksLiveData?.observe(this, Observer { booksLiveData?.observe(this, Observer {

Loading…
Cancel
Save