diff --git a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt index 8e37c5b88..1035fd957 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt @@ -27,7 +27,6 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import kotlin.math.min class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapter_list), ChapterListAdapter.Callback, @@ -115,7 +114,7 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapt }.collect { if (!(searchKey.isNullOrBlank() && it.isEmpty())) { adapter.setItems(it, adapter.diffCallBack) - if (searchKey.isNullOrBlank()) { + if (searchKey.isNullOrBlank() && mLayoutManager.findFirstVisibleItemPosition() < 0) { mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) } } @@ -127,7 +126,7 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapt get() = viewModel.bookData.value?.isLocalBook() == true override fun durChapterIndex(): Int { - return min(durChapterIndex, adapter.itemCount) + return durChapterIndex } override fun openChapter(bookChapter: BookChapter) {