From ba37b489694999aad8d96d52045d2de35f9d67de Mon Sep 17 00:00:00 2001
From: gongym <1967988842@qq.com>
Date: Mon, 24 May 2021 12:51:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E4=B8=8B=E6=BB=91?=
=?UTF-8?q?=E5=8A=A8=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=B7=A6=E5=8F=B3=E5=88=87?=
=?UTF-8?q?=E6=8D=A2=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86?=
=?UTF-8?q?=E6=96=B0=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BB=84=E4=BB=B6?=
=?UTF-8?q?RecyclerViewAtViewPager2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ui/widget/RecyclerViewAtViewPager2.java | 55 +++++++++++++++++++
app/src/main/res/layout/fragment_books.xml | 2 +-
app/src/main/res/layout/fragment_explore.xml | 2 +-
app/src/main/res/layout/fragment_rss.xml | 2 +-
.../main/res/layout/fragment_rss_articles.xml | 2 +-
5 files changed, 59 insertions(+), 4 deletions(-)
create mode 100644 app/src/main/java/io/legado/app/ui/widget/RecyclerViewAtViewPager2.java
diff --git a/app/src/main/java/io/legado/app/ui/widget/RecyclerViewAtViewPager2.java b/app/src/main/java/io/legado/app/ui/widget/RecyclerViewAtViewPager2.java
new file mode 100644
index 000000000..f701b1a14
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/widget/RecyclerViewAtViewPager2.java
@@ -0,0 +1,55 @@
+package io.legado.app.ui.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
+public class RecyclerViewAtViewPager2 extends RecyclerView {
+
+ public RecyclerViewAtViewPager2(@NonNull Context context) {
+ super(context);
+ }
+
+ public RecyclerViewAtViewPager2(@NonNull Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public RecyclerViewAtViewPager2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ private int startX, startY;
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ startX = (int) ev.getX();
+ startY = (int) ev.getY();
+ getParent().requestDisallowInterceptTouchEvent(true);
+ break;
+ case MotionEvent.ACTION_MOVE:
+ int endX = (int) ev.getX();
+ int endY = (int) ev.getY();
+ int disX = Math.abs(endX - startX);
+ int disY = Math.abs(endY - startY);
+ if (disX > disY) {
+ if (disX > 50) {
+ getParent().requestDisallowInterceptTouchEvent(false);
+ }
+ } else {
+ getParent().requestDisallowInterceptTouchEvent(true);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_CANCEL:
+ getParent().requestDisallowInterceptTouchEvent(false);
+ break;
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+}
diff --git a/app/src/main/res/layout/fragment_books.xml b/app/src/main/res/layout/fragment_books.xml
index 8da85f913..1e2fbe64b 100644
--- a/app/src/main/res/layout/fragment_books.xml
+++ b/app/src/main/res/layout/fragment_books.xml
@@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
-
-