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 lateinit var mLayoutManager: UpLinearLayoutManager
|
||||
private var tocFlowJob: Job? = null
|
||||
private var isFirstSetData = true
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
|
||||
viewModel.chapterCallBack = this@ChapterListFragment
|
||||
@ -114,10 +113,11 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
||||
searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl)
|
||||
else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey)
|
||||
}.collect {
|
||||
if (!(searchKey.isNullOrBlank() && it.isEmpty())) {
|
||||
adapter.setItems(it, adapter.diffCallBack)
|
||||
if (isFirstSetData) {
|
||||
if (searchKey.isNullOrBlank()) {
|
||||
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
|
||||
isFirstSetData = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user