From ed5336672529fb4a4789e74df08946173b1582c5 Mon Sep 17 00:00:00 2001 From: Robb <35880555+robbwatershed@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:22:43 +0100 Subject: [PATCH] Reader : Fix page details panel showing up (cont'ed) --- .../devsaki/hentoid/adapters/ImagePagerAdapter.kt | 14 ++++++++------ .../fragments/reader/ReaderPagerFragment.kt | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/me/devsaki/hentoid/adapters/ImagePagerAdapter.kt b/app/src/main/java/me/devsaki/hentoid/adapters/ImagePagerAdapter.kt index ec1db3943..083ece958 100644 --- a/app/src/main/java/me/devsaki/hentoid/adapters/ImagePagerAdapter.kt +++ b/app/src/main/java/me/devsaki/hentoid/adapters/ImagePagerAdapter.kt @@ -310,13 +310,15 @@ class ImagePagerAdapter(context: Context) : this.isScrollLTR = isScrollLTR } - fun adjustBehaviourForPosition(position: Int) { + fun adjustBehaviourForPosition(position: Int, immediate : Boolean = false) { recyclerView?.lifecycleScope?.launch { - withContext(Dispatchers.Default) { - // Account for items being refreshed just after that call - // NB : A cleaner implementation would be to intercept all notifyxxxChanged calls and set a debouncer on them, - // but it would add complexity for little perceived value - pause(500) + if (!immediate) { + withContext(Dispatchers.Default) { + // Account for items being refreshed just after that call + // NB : A cleaner implementation would be to intercept all notifyxxxChanged calls and set a debouncer on them, + // but it would add complexity for little perceived value + pause(500) + } } (recyclerView?.findViewHolderForAdapterPosition(position) as ImageViewHolder?)?.apply { Timber.d("adjustBehaviourForPosition $position") diff --git a/app/src/main/java/me/devsaki/hentoid/fragments/reader/ReaderPagerFragment.kt b/app/src/main/java/me/devsaki/hentoid/fragments/reader/ReaderPagerFragment.kt index 6bb522737..80cd0febf 100644 --- a/app/src/main/java/me/devsaki/hentoid/fragments/reader/ReaderPagerFragment.kt +++ b/app/src/main/java/me/devsaki/hentoid/fragments/reader/ReaderPagerFragment.kt @@ -873,6 +873,7 @@ class ReaderPagerFragment : Fragment(R.layout.fragment_reader_pager), adjustDisplay(bookPreferences, absImageIndex) } } + adapter.adjustBehaviourForPosition(absImageIndex, true) if (VIEWER_ORIENTATION_VERTICAL == displayParams?.orientation) slideshowMgr.onPageChange(true) viewModel.onPageChange(absImageIndex, scrollDirection) @@ -886,7 +887,7 @@ class ReaderPagerFragment : Fragment(R.layout.fragment_reader_pager), private fun onScrollPositionReached(position: Int) { if (position == absImageIndex || position == reachedPosition) return reachedPosition = position - adapter.adjustBehaviourForPosition(position) + adapter.adjustBehaviourForPosition(position, true) } /**