From 8e9609c886abebbfcacf7cf72103195f5d844c68 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 12 Mar 2020 19:07:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/chapterlist/ChapterListFragment.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt index 51c8b8096..d717cb25f 100644 --- a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt @@ -36,6 +36,7 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme private var durChapterIndex = 0 private lateinit var mLayoutManager: UpLinearLayoutManager private var tocLiveData: LiveData>? = null + private var scrollToDurChapter = false override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { viewModel.chapterCallBack = this @@ -74,7 +75,6 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme book?.let { durChapterIndex = it.durChapterIndex tv_current_chapter_info.text = it.durChapterTitle - mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) initCacheFileNames(it) } } @@ -85,7 +85,10 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme tocLiveData = App.db.bookChapterDao().observeByBook(viewModel.bookUrl) tocLiveData?.observe(viewLifecycleOwner, Observer { adapter.setItems(it) - mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) + if (!scrollToDurChapter) { + mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) + scrollToDurChapter = true + } }) }