From 907599b7d22601f12c8d91984212d993c488075f Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 11 May 2021 14:19:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/main/bookshelf/RootView.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/RootView.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/RootView.kt index 0e8225fc0..95ee7b755 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/RootView.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/RootView.kt @@ -25,7 +25,7 @@ class RootView : LinearLayout { private val parentViewPager: ViewPager2? get() = (activity as? MainActivity)?.getViewPager() - private val childViewPager: View + private val childViewPager: View? get() = findViewById(R.id.view_pager_bookshelf) init { @@ -35,8 +35,8 @@ class RootView : LinearLayout { private fun canChildScroll(orientation: Int, delta: Float): Boolean { val direction = -delta.sign.toInt() return when (orientation) { - 0 -> childViewPager.canScrollHorizontally(direction) - 1 -> childViewPager.canScrollVertically(direction) + 0 -> childViewPager?.canScrollHorizontally(direction) ?: false + 1 -> childViewPager?.canScrollVertically(direction) ?: false else -> throw IllegalArgumentException() } }