mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
6b35a1251a
commit
785412ab2b
@ -38,7 +38,6 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
|||||||
private var durChapterIndex = 0
|
private var durChapterIndex = 0
|
||||||
private lateinit var mLayoutManager: UpLinearLayoutManager
|
private lateinit var mLayoutManager: UpLinearLayoutManager
|
||||||
private var tocFlowJob: Job? = null
|
private var tocFlowJob: Job? = null
|
||||||
private var isFirstSetData = true
|
|
||||||
|
|
||||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
|
||||||
viewModel.chapterCallBack = this@ChapterListFragment
|
viewModel.chapterCallBack = this@ChapterListFragment
|
||||||
@ -114,10 +113,11 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
|||||||
searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl)
|
searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl)
|
||||||
else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey)
|
else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey)
|
||||||
}.collect {
|
}.collect {
|
||||||
adapter.setItems(it, adapter.diffCallBack)
|
if (!(searchKey.isNullOrBlank() && it.isEmpty())) {
|
||||||
if (isFirstSetData) {
|
adapter.setItems(it, adapter.diffCallBack)
|
||||||
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
|
if (searchKey.isNullOrBlank()) {
|
||||||
isFirstSetData = false
|
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user