Преглед изворни кода

fix scrollView顶部时下拉刷新

Xwite пре 3 година
родитељ
комит
402f9e91d4

+ 5 - 6
app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt

@@ -423,13 +423,12 @@ class BookInfoActivity :
                 }
                 }
             }
             }
         }
         }
-
+        scrollView.setOnScrollChangeListener { _, _, scrollY, _, _ ->
+            refreshLayout?.isEnabled = (scrollY <= 0)
+        }
         refreshLayout?.setOnRefreshListener {
         refreshLayout?.setOnRefreshListener {
-            // scrollView 顶部
-            if (scrollView.scrollY <= 0) {
-                refreshLayout.isRefreshing = false
-                refreshBook()
-            }
+            refreshLayout.isRefreshing = false
+            refreshBook()
         }
         }
     }
     }
 
 

+ 1 - 1
app/src/main/res/layout/activity_book_info.xml

@@ -399,6 +399,6 @@
 
 
         </LinearLayout>
         </LinearLayout>
 
 
-    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
 
 </androidx.constraintlayout.widget.ConstraintLayout>
 </androidx.constraintlayout.widget.ConstraintLayout>