From ef1b14cc6ae1ddf03e2e410e9df69d0aad4160ab Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sun, 13 Nov 2022 18:25:30 +1100 Subject: Swipe to view images in a gallery in Card Layout 2. --- .../activities/AccountSavedThingActivity.java | 5 - .../infinityforreddit/activities/BaseActivity.java | 4 - .../adapters/PostRecyclerViewAdapter.java | 220 +++++++++++++++------ .../infinityforreddit/fragments/PostFragment.java | 4 +- 4 files changed, 165 insertions(+), 68 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java index b9ffb7fe..90364417 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java @@ -243,11 +243,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT } } - @Override - public void toggleViewPagerSwipeLock(boolean lock) { - binding.accountSavedThingViewPager2.setUserInputEnabled(!lock); - } - @Override public void postLayoutSelected(int postLayout) { if (sectionsPagerAdapter != null) { 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 de0b8947..02c20b77 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java @@ -400,8 +400,4 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo public void unlockSwipeRightToGoBack() { } - - public void toggleViewPagerSwipeLock(boolean lock) { - - } } \ No newline at end of file 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 6c52426b..aec73069 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -87,6 +87,7 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; +import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding; import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostDetailFragment; import ml.docilealligator.infinityforreddit.fragments.PostFragment; @@ -120,7 +121,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override @@ -429,8 +431,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + rootView.setOnTouchListener((view, motionEvent) -> { swipeLocked = false; return false; }); - binding.bottomConstraintLayoutItemPostGalleryType.setOnTouchListener((view, motionEvent) -> { + bottomConstraintLayout.setOnTouchListener((view, motionEvent) -> { swipeLocked = false; return false; }); - binding.noPreviewImageViewItemPostGalleryType.setOnClickListener(view -> { + noPreviewImageView.setOnClickListener(view -> { int position = getBindingAdapterPosition(); if (position < 0) { return; @@ -3253,6 +3291,39 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter