From 065af144f24ca9721a9b270338f98b271dd2db4e Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:46:08 -0400 Subject: Refine horizontal gestures on gallery posts. --- .../adapters/PostDetailRecyclerViewAdapter.java | 50 +++++++----- .../adapters/PostRecyclerViewAdapter.java | 93 ++++++++-------------- 2 files changed, 59 insertions(+), 84 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 75d7fcbf..8ef71a7e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -2271,27 +2271,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { - if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) { - if (mActivity.mSliderPanel != null) { - mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); - } - if (mActivity.mViewPager2 != null) { - mActivity.mViewPager2.setUserInputEnabled(true); - } - mActivity.unlockSwipeRightToGoBack(); - } else { - if (mActivity.mSliderPanel != null) { - mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); - } - if (mActivity.mViewPager2 != null) { - mActivity.mViewPager2.setUserInputEnabled(false); - } - mActivity.lockSwipeRightToGoBack(); - } - - return false; - }); LinearLayoutManagerBugFixed layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false); binding.galleryRecyclerViewItemPostDetailGallery.setLayoutManager(layoutManager); binding.galleryRecyclerViewItemPostDetailGallery.addOnScrollListener(new RecyclerView.OnScrollListener() { @@ -2323,6 +2302,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) { @@ -2334,9 +2321,18 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter= 0) { @@ -2351,6 +2347,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { - if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) { - if (mFragment.isRecyclerViewItemSwipeable(this)) { - mActivity.unlockSwipeRightToGoBack(); - } - } else { - if (mFragment.isRecyclerViewItemSwipeable(this)) { - mActivity.lockSwipeRightToGoBack(); - } - } - return false; - }); - upvoteButton.setOnClickListener(view -> { int position = getBindingAdapterPosition(); if (position < 0) { @@ -3366,30 +3354,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) { - if (mActivity.mSliderPanel != null) { - mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); - } - - if (mActivity.mViewPager2 != null) { - mActivity.mViewPager2.setUserInputEnabled(true); - } - mActivity.unlockSwipeRightToGoBack(); - swipeLocked = false; - } else { - if (mActivity.mSliderPanel != null) { - mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); - } - if (mActivity.mViewPager2 != null) { - mActivity.mViewPager2.setUserInputEnabled(false); - } - mActivity.lockSwipeRightToGoBack(); - swipeLocked = true; - } - - return false; - }); new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView); galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool); LinearLayoutManagerBugFixed layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false); @@ -3434,7 +3398,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) { + if (Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) { dragged = true; } @@ -3455,7 +3419,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter= 0) { @@ -4089,27 +4054,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) { - if (mActivity.mSliderPanel != null) { - mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); - } - if (mActivity.mViewPager2 != null) { - mActivity.mViewPager2.setUserInputEnabled(true); - } - mActivity.unlockSwipeRightToGoBack(); - } else { - if (mActivity.mSliderPanel != null) { - mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); - } - if (mActivity.mViewPager2 != null) { - mActivity.mViewPager2.setUserInputEnabled(false); - } - mActivity.lockSwipeRightToGoBack(); - } - - return false; - }); recyclerView.setAdapter(adapter); new PagerSnapHelper().attachToRecyclerView(recyclerView); recyclerView.setRecycledViewPool(mGalleryRecycledViewPool); @@ -4144,6 +4088,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) { @@ -4155,18 +4107,35 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter