pull/981/head
gedoor 4 years ago
parent c0634eb5cf
commit 907599b7d2
  1. 6
      app/src/main/java/io/legado/app/ui/main/bookshelf/RootView.kt

@ -25,7 +25,7 @@ class RootView : LinearLayout {
private val parentViewPager: ViewPager2? private val parentViewPager: ViewPager2?
get() = (activity as? MainActivity)?.getViewPager() get() = (activity as? MainActivity)?.getViewPager()
private val childViewPager: View private val childViewPager: View?
get() = findViewById(R.id.view_pager_bookshelf) get() = findViewById(R.id.view_pager_bookshelf)
init { init {
@ -35,8 +35,8 @@ class RootView : LinearLayout {
private fun canChildScroll(orientation: Int, delta: Float): Boolean { private fun canChildScroll(orientation: Int, delta: Float): Boolean {
val direction = -delta.sign.toInt() val direction = -delta.sign.toInt()
return when (orientation) { return when (orientation) {
0 -> childViewPager.canScrollHorizontally(direction) 0 -> childViewPager?.canScrollHorizontally(direction) ?: false
1 -> childViewPager.canScrollVertically(direction) 1 -> childViewPager?.canScrollVertically(direction) ?: false
else -> throw IllegalArgumentException() else -> throw IllegalArgumentException()
} }
} }

Loading…
Cancel
Save