From a3d0beb40c33d5a67ee157b440923d2df277aa17 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 19 Jul 2021 19:22:02 -0400 Subject: [PATCH] Fix the readernav disappearing on theme switching --- .../ui/reader/chapter/ReaderChapterSheet.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt index b5f93c6ed4..509a6ba550 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt @@ -7,7 +7,6 @@ import android.util.AttributeSet import android.view.View import android.widget.LinearLayout import androidx.core.graphics.ColorUtils -import androidx.core.view.isGone import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager @@ -68,7 +67,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr binding.chapterRecycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f binding.chapterRecycler.isClickable = sheetBehavior.isExpanded() binding.chapterRecycler.isFocusable = sheetBehavior.isExpanded() - if (!activity.binding.readerNav.root.isGone) { + val canShowNav = presenter.getCurrentChapter()?.pages?.size ?: 1 > 1 + if (canShowNav) { activity.binding.readerNav.root.isVisible = sheetBehavior.isCollapsed() } } @@ -89,24 +89,25 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr } override fun onStateChanged(p0: View, state: Int) { + val canShowNav = presenter.getCurrentChapter()?.pages?.size ?: 1 > 1 if (state == BottomSheetBehavior.STATE_COLLAPSED) { sheetBehavior?.isHideable = false (binding.chapterRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0, binding.chapterRecycler.height / 2 - 30.dpToPx ) - if (!activity.binding.readerNav.root.isGone) { + if (canShowNav) { activity.binding.readerNav.root.isVisible = true } activity.binding.readerNav.root.alpha = 1f } if (state == BottomSheetBehavior.STATE_DRAGGING || state == BottomSheetBehavior.STATE_SETTLING) { - if (!activity.binding.readerNav.root.isGone) { + if (canShowNav) { activity.binding.readerNav.root.isVisible = true } } if (state == BottomSheetBehavior.STATE_EXPANDED) { - if (!activity.binding.readerNav.root.isGone) { + if (canShowNav) { activity.binding.readerNav.root.isInvisible = true } activity.binding.readerNav.root.alpha = 0f @@ -115,7 +116,7 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr } if (state == BottomSheetBehavior.STATE_HIDDEN) { activity.binding.readerNav.root.alpha = 0f - if (!activity.binding.readerNav.root.isGone) { + if (canShowNav) { activity.binding.readerNav.root.isInvisible = true } }