From df79433a6a387ff7b14f25aebdefe343c4dc58b6 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:06:21 +0800 Subject: Try fixing gallery images swipe gesture and Slidr gesture conflicts. --- .../infinityforreddit/activities/BaseActivity.java | 2 ++ .../infinityforreddit/activities/FilteredPostsActivity.java | 2 +- .../infinityforreddit/adapters/PostRecyclerViewAdapter.java | 10 ++++++++++ .../customviews/slidr/widget/SliderPanel.java | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java index 6c734576..34d932ab 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java @@ -48,6 +48,7 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.CustomFontReceiver; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel; import ml.docilealligator.infinityforreddit.font.ContentFontFamily; import ml.docilealligator.infinityforreddit.font.ContentFontStyle; import ml.docilealligator.infinityforreddit.font.FontFamily; @@ -70,6 +71,7 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo public Typeface typeface; public Typeface titleTypeface; public Typeface contentTypeface; + public SliderPanel sliderPanel; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java index 28d6c177..fc2811e6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -121,7 +121,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec applyCustomTheme(); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) { - Slidr.attach(this); + sliderPanel = Slidr.attach(this); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 08c91772..66e6870f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -3292,6 +3292,16 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + mActivity.sliderPanel.requestDisallowInterceptTouchEvent(true); + + switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) { + case MotionEvent.ACTION_UP: + mActivity.sliderPanel.requestDisallowInterceptTouchEvent(false); + } + + return false; + }); new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView); galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool); SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager( diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/slidr/widget/SliderPanel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/slidr/widget/SliderPanel.java index fe8ea871..f23394f9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/slidr/widget/SliderPanel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/slidr/widget/SliderPanel.java @@ -48,6 +48,10 @@ public class SliderPanel extends FrameLayout { init(); } + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + return super.dispatchTouchEvent(ev); + } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { -- cgit v1.2.3