Fixed gallery images swipe gesture and Slidr gesture conflicts in all places.

This commit is contained in:
Docile-Alligator 2023-04-28 22:21:15 +08:00
parent 9308bc3714
commit d65a355bdc
13 changed files with 105 additions and 120 deletions

View File

@ -91,6 +91,8 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
mSliderPanel = Slidr.attach(this); mSliderPanel = Slidr.attach(this);
} }
mViewPager2 = binding.accountSavedThingViewPager2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -73,6 +73,8 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
public Typeface contentTypeface; public Typeface contentTypeface;
@Nullable @Nullable
public SliderPanel mSliderPanel; public SliderPanel mSliderPanel;
@Nullable
public ViewPager2 mViewPager2;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {

View File

@ -94,6 +94,8 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
mSliderPanel = Slidr.attach(this); mSliderPanel = Slidr.attach(this);
} }
//mViewPager2 = viewPager2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -316,6 +316,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}); });
toggle.syncState(); toggle.syncState();
mViewPager2 = viewPager2;
mBackButtonAction = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION, "0")); mBackButtonAction = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION, "0"));
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false); mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
mDisableSwipingBetweenTabs = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false); mDisableSwipingBetweenTabs = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false);

View File

@ -63,7 +63,6 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchUserAndSu
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.fragments.PostFragment; import ml.docilealligator.infinityforreddit.fragments.PostFragment;
@ -158,6 +157,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
mSliderPanel = Slidr.attach(this); mSliderPanel = Slidr.attach(this);
} }
mViewPager2 = viewPager2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();

View File

@ -70,8 +70,6 @@ import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
import ml.docilealligator.infinityforreddit.comment.Comment; import ml.docilealligator.infinityforreddit.comment.Comment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
import ml.docilealligator.infinityforreddit.events.NeedForPostListFromPostFragmentEvent; import ml.docilealligator.infinityforreddit.events.NeedForPostListFromPostFragmentEvent;
import ml.docilealligator.infinityforreddit.events.ProvidePostListToViewPostDetailActivityEvent; import ml.docilealligator.infinityforreddit.events.ProvidePostListToViewPostDetailActivityEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
@ -186,7 +184,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private boolean mVolumeKeysNavigateComments; private boolean mVolumeKeysNavigateComments;
private boolean isNsfwSubreddit; private boolean isNsfwSubreddit;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
@ -240,6 +237,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
mSliderPanel = Slidr.attach(this); mSliderPanel = Slidr.attach(this);
} }
viewPager2.setUserInputEnabled(false); viewPager2.setUserInputEnabled(false);
} else {
super.mViewPager2 = viewPager2;
} }
postFragmentId = getIntent().getLongExtra(EXTRA_POST_FRAGMENT_ID, -1); postFragmentId = getIntent().getLongExtra(EXTRA_POST_FRAGMENT_ID, -1);
if (swipeBetweenPosts && posts == null && postFragmentId > 0) { if (swipeBetweenPosts && posts == null && postFragmentId > 0) {
@ -860,20 +859,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
} }
} }
@Override
public void lockSwipeRightToGoBack() {
if (mSliderPanel != null) {
mSliderPanel.lock();
}
}
@Override
public void unlockSwipeRightToGoBack() {
if (mSliderPanel != null) {
mSliderPanel.unlock();
}
}
@Override @Override
public void onLongPress() { public void onLongPress() {
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment(); ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();

View File

@ -252,6 +252,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
mSliderPanel = Slidr.attach(this); mSliderPanel = Slidr.attach(this);
} }
mViewPager2 = viewPager2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow(); Window window = getWindow();
if (isImmersiveInterface()) { if (isImmersiveInterface()) {

View File

@ -256,6 +256,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mSliderPanel = Slidr.attach(this); mSliderPanel = Slidr.attach(this);
} }
mViewPager2 = viewPager2;
username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY); username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY);
fragmentManager = getSupportFragmentManager(); fragmentManager = getSupportFragmentManager();

View File

@ -40,12 +40,10 @@ import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing; import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity;
import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CommentMoreBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.CommentMoreBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.comment.Comment; import ml.docilealligator.infinityforreddit.comment.Comment;
@ -506,20 +504,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() { LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override @Override
public void lockSwipe() { public void lockSwipe() {
if (mActivity instanceof AccountSavedThingActivity) { mActivity.lockSwipeRightToGoBack();
((AccountSavedThingActivity) mActivity).lockSwipeRightToGoBack();
} else {
((ViewUserDetailActivity) mActivity).lockSwipeRightToGoBack();
}
} }
@Override @Override
public void unlockSwipe() { public void unlockSwipe() {
if (mActivity instanceof AccountSavedThingActivity) { mActivity.unlockSwipeRightToGoBack();
((AccountSavedThingActivity) mActivity).unlockSwipeRightToGoBack();
} else {
((ViewUserDetailActivity) mActivity).unlockSwipeRightToGoBack();
}
} }
}); });
commentMarkdownView.setLayoutManager(linearLayoutManager); commentMarkdownView.setLayoutManager(linearLayoutManager);

View File

@ -87,8 +87,7 @@ import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding;
@ -3155,12 +3154,25 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface, adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale); mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> { galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) { if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(true);
}
mActivity.unlockSwipeRightToGoBack();
swipeLocked = false;
} else { } else {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
} }
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(false);
}
mActivity.lockSwipeRightToGoBack();
swipeLocked = true;
} }
return false; return false;
@ -3168,25 +3180,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
galleryRecyclerView.setAdapter(adapter); galleryRecyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView); new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView);
galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool); galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager( LinearLayoutManagerBugFixed layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false);
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() {
@Override
public void lockSwipe() {
mActivity.lockSwipeRightToGoBack();
swipeLocked = true;
}
@Override
public void unlockSwipe() {
mActivity.unlockSwipeRightToGoBack();
swipeLocked = false;
}
@Override
public void setSwipeLocked(boolean swipeLocked) {
PostBaseGalleryTypeViewHolder.this.swipeLocked = swipeLocked;
}
});
galleryRecyclerView.setLayoutManager(layoutManager); galleryRecyclerView.setLayoutManager(layoutManager);
galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
@ -4192,7 +4186,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
ImageView noPreviewImageView; ImageView noPreviewImageView;
PostGalleryTypeImageRecyclerViewAdapter adapter; PostGalleryTypeImageRecyclerViewAdapter adapter;
private SwipeLockLinearLayoutManager layoutManager; private LinearLayoutManagerBugFixed layoutManager;
Post post; Post post;
Post.Preview preview; Post.Preview preview;
@ -4226,12 +4220,22 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface, adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale); mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
recyclerView.setOnTouchListener((v, motionEvent) -> { recyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) { if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(true);
}
mActivity.unlockSwipeRightToGoBack();
} else { } else {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
} }
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(false);
}
mActivity.lockSwipeRightToGoBack();
} }
return false; return false;
@ -4239,18 +4243,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(recyclerView); new PagerSnapHelper().attachToRecyclerView(recyclerView);
recyclerView.setRecycledViewPool(mGalleryRecycledViewPool); recyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
layoutManager = new SwipeLockLinearLayoutManager( layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false);
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() {
@Override
public void lockSwipe() {
mActivity.lockSwipeRightToGoBack();
}
@Override
public void unlockSwipe() {
mActivity.unlockSwipeRightToGoBack();
}
});
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override

View File

@ -96,6 +96,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottom
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment; import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
@ -2421,18 +2422,28 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mCardViewColor, mCommentColor, mScale); mCardViewColor, mCommentColor, mScale);
galleryRecyclerView.setAdapter(adapter); galleryRecyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView); new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView);
SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager( galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
@Override if (mActivity.mSliderPanel != null) {
public void lockSwipe() { 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(); mActivity.lockSwipeRightToGoBack();
} }
@Override return false;
public void unlockSwipe() {
mActivity.unlockSwipeRightToGoBack();
}
}); });
LinearLayoutManagerBugFixed layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false);
galleryRecyclerView.setLayoutManager(layoutManager); galleryRecyclerView.setLayoutManager(layoutManager);
galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override

View File

@ -88,8 +88,7 @@ import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding;
@ -3293,37 +3292,32 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale); mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
galleryRecyclerView.setAdapter(adapter); galleryRecyclerView.setAdapter(adapter);
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> { galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) { if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(true);
}
mActivity.unlockSwipeRightToGoBack();
swipeLocked = false;
} else { } else {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
} }
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(false);
}
mActivity.lockSwipeRightToGoBack();
swipeLocked = true;
} }
return false; return false;
}); });
new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView); new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView);
galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool); galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager( LinearLayoutManagerBugFixed layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false);
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() {
@Override
public void lockSwipe() {
mActivity.lockSwipeRightToGoBack();
swipeLocked = true;
}
@Override
public void unlockSwipe() {
mActivity.unlockSwipeRightToGoBack();
swipeLocked = false;
}
@Override
public void setSwipeLocked(boolean swipeLocked) {
PostBaseGalleryTypeViewHolder.this.swipeLocked = swipeLocked;
}
});
galleryRecyclerView.setLayoutManager(layoutManager); galleryRecyclerView.setLayoutManager(layoutManager);
galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
@ -4377,7 +4371,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView noPreviewImageView; ImageView noPreviewImageView;
PostGalleryTypeImageRecyclerViewAdapter adapter; PostGalleryTypeImageRecyclerViewAdapter adapter;
private SwipeLockLinearLayoutManager layoutManager; private LinearLayoutManagerBugFixed layoutManager;
Post post; Post post;
Post.Preview preview; Post.Preview preview;
@ -4411,12 +4405,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface, adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale); mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
recyclerView.setOnTouchListener((v, motionEvent) -> { recyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) { if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(true);
}
mActivity.unlockSwipeRightToGoBack();
} else { } else {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true); mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
} }
if (mActivity.mViewPager2 != null) {
mActivity.mViewPager2.setUserInputEnabled(false);
}
mActivity.lockSwipeRightToGoBack();
} }
return false; return false;
@ -4424,18 +4428,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(recyclerView); new PagerSnapHelper().attachToRecyclerView(recyclerView);
recyclerView.setRecycledViewPool(mGalleryRecycledViewPool); recyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
layoutManager = new SwipeLockLinearLayoutManager( layoutManager = new LinearLayoutManagerBugFixed(mActivity, RecyclerView.HORIZONTAL, false);
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() {
@Override
public void lockSwipe() {
mActivity.lockSwipeRightToGoBack();
}
@Override
public void unlockSwipe() {
mActivity.unlockSwipeRightToGoBack();
}
});
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -89,4 +89,4 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayout> </LinearLayout>