Fixed gallery images swipe gesture and Slidr gesture conflicts.

This commit is contained in:
Docile-Alligator 2023-04-28 00:10:15 +08:00
parent df79433a6a
commit 9308bc3714
17 changed files with 44 additions and 26 deletions

View File

@ -27,7 +27,6 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
import ml.docilealligator.infinityforreddit.databinding.ActivityAccountPostsBinding;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
@ -53,7 +52,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
private SliderPanel mSliderPanel;
private String mAccessToken;
private String mAccountName;
private String mUserWhere;

View File

@ -35,7 +35,6 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
import ml.docilealligator.infinityforreddit.databinding.ActivityAccountSavedThingBinding;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
@ -71,7 +70,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
Executor mExecutor;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private SliderPanel mSliderPanel;
private String mAccessToken;
private String mAccountName;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;

View File

@ -71,7 +71,8 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
public Typeface typeface;
public Typeface titleTypeface;
public Typeface contentTypeface;
public SliderPanel sliderPanel;
@Nullable
public SliderPanel mSliderPanel;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {

View File

@ -124,8 +124,7 @@ public class EditProfileActivity extends BaseActivity {
setSupportActionBar(toolbar);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
SliderPanel sliderPanel = Slidr.attach(this);
sliderPanel.unlock();
Slidr.attach(this);
}
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);

View File

@ -121,7 +121,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
sliderPanel = Slidr.attach(this);
mSliderPanel = Slidr.attach(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View File

@ -42,7 +42,6 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@ -68,7 +67,6 @@ public class FullMarkdownActivity extends BaseActivity {
SharedPreferences mSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
private SliderPanel mSliderPanel;
@Override
protected void onCreate(Bundle savedInstanceState) {

View File

@ -38,7 +38,6 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
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.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.fragments.CommentsListingFragment;
@ -74,7 +73,6 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
CustomThemeWrapper mCustomThemeWrapper;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private SliderPanel mSliderPanel;
private String mAccessToken;
private String mAccountName;

View File

@ -103,7 +103,6 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
private SliderPanel mSliderPanel;
private SectionsPagerAdapter sectionsPagerAdapter;
private FragmentManager fragmentManager;
private String mAccessToken;

View File

@ -138,7 +138,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private boolean mInsertSearchQuerySuccess;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private SliderPanel mSliderPanel;
private int fabOption;
@Override

View File

@ -112,7 +112,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
private SliderPanel mSliderPanel;
private String mAccessToken;
private String mAccountName;
private boolean mInsertSuccess = false;

View File

@ -170,7 +170,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
mSliderPanel = Slidr.attach(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View File

@ -177,7 +177,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
int loadingMorePostsStatus = LoadingMorePostsStatus.NOT_LOADING;
public Map<String, String> authorIcons = new HashMap<>();
private FragmentManager fragmentManager;
private SliderPanel mSliderPanel;
private SectionsPagerAdapter sectionsPagerAdapter;
private String mAccessToken;
private String mAccountName;

View File

@ -224,7 +224,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int unsubscribedColor;
private int subscribedColor;
private int fabOption;
private SliderPanel mSliderPanel;
private MaterialAlertDialogBuilder nsfwWarningBuilder;
@Override

View File

@ -226,7 +226,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private boolean lockBottomAppBar;
private String mMessageFullname;
private String mNewAccountName;
private SliderPanel mSliderPanel;
//private MaterialAlertDialogBuilder nsfwWarningBuilder;
@Override

View File

@ -95,7 +95,6 @@ public class WikiActivity extends BaseActivity {
SharedPreferences mSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
private SliderPanel mSliderPanel;
private String wikiMarkdown;
private Markwon markwon;
private MarkwonAdapter markwonAdapter;

View File

@ -67,7 +67,6 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
import ml.docilealligator.infinityforreddit.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
import ml.docilealligator.infinityforreddit.SaveThing;
@ -3155,6 +3154,17 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
} else {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
}
}
return false;
});
galleryRecyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView);
galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
@ -4215,6 +4225,17 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
recyclerView.setOnTouchListener((v, motionEvent) -> {
if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
} else {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
}
}
return false;
});
recyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(recyclerView);
recyclerView.setRecycledViewPool(mGalleryRecycledViewPool);

View File

@ -3293,11 +3293,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
galleryRecyclerView.setAdapter(adapter);
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
mActivity.sliderPanel.requestDisallowInterceptTouchEvent(true);
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
mActivity.sliderPanel.requestDisallowInterceptTouchEvent(false);
if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
} else {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
}
}
return false;
@ -4409,6 +4410,17 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
recyclerView.setOnTouchListener((v, motionEvent) -> {
if (mActivity.mSliderPanel != null) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
} else {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
}
}
return false;
});
recyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(recyclerView);
recyclerView.setRecycledViewPool(mGalleryRecycledViewPool);