From d2c240d02f349f8a1f7fda0f55a134785f315c6a Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:05:24 -0400 Subject: Long click the preview image to open PostOptionsBottomSheetFragment. --- .../adapters/HistoryPostRecyclerViewAdapter.java | 9 ++++++--- .../adapters/PostDetailRecyclerViewAdapter.java | 3 ++- .../PostGalleryTypeImageRecyclerViewAdapter.java | 18 ++++++++++++++++-- .../adapters/PostRecyclerViewAdapter.java | 12 ++++++++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java index 8b6ca8d1..4861e6a6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java @@ -3656,7 +3656,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter itemView.performLongClick()); galleryRecyclerView.setOnTouchListener((v, motionEvent) -> { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) { if (mActivity.mSliderPanel != null) { @@ -4613,7 +4614,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter {}); recyclerView.setOnTouchListener((v, motionEvent) -> { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) { if (mActivity.mSliderPanel != null) { @@ -6235,7 +6237,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter itemView.performLongClick()); galleryRecyclerView.setOnTouchListener((v, motionEvent) -> { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) { if (mActivity.mSliderPanel != null) { 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 9b94485f..1112cf51 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -2268,7 +2268,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter {}); binding.galleryRecyclerViewItemPostDetailGallery.setAdapter(adapter); new PagerSnapHelper().attachToRecyclerView(binding.galleryRecyclerViewItemPostDetailGallery); binding.galleryRecyclerViewItemPostDetailGallery.setOnTouchListener((v, motionEvent) -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java index 386e29f9..27ea1832 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java @@ -44,23 +44,27 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte private boolean blurImage; private float ratio; private final boolean showCaption; + private ItemClickListener itemClickListener; public PostGalleryTypeImageRecyclerViewAdapter(RequestManager glide, Typeface typeface, SaveMemoryCenterInisdeDownsampleStrategy saveMemoryCenterInisdeDownsampleStrategy, - int mColorAccent, int mPrimaryTextColor, float scale) { + int mColorAccent, int mPrimaryTextColor, float scale, + ItemClickListener itemClickListener) { this.glide = glide; this.typeface = typeface; this.saveMemoryCenterInisdeDownsampleStrategy = saveMemoryCenterInisdeDownsampleStrategy; this.mColorAccent = mColorAccent; this.mPrimaryTextColor = mPrimaryTextColor; this.mScale = scale; + this.itemClickListener = itemClickListener; showCaption = false; } public PostGalleryTypeImageRecyclerViewAdapter(RequestManager glide, Typeface typeface, Markwon postDetailMarkwon, SaveMemoryCenterInisdeDownsampleStrategy saveMemoryCenterInisdeDownsampleStrategy, int mColorAccent, int mPrimaryTextColor, int mCardViewColor, - int mCommentColor, float scale) { + int mCommentColor, float scale, + ItemClickListener itemClickListener) { this.glide = glide; this.typeface = typeface; this.mPostDetailMarkwon = postDetailMarkwon; @@ -70,6 +74,7 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte this.mCardViewColor = mCardViewColor; this.mCommentColor = mCommentColor; this.mScale = scale; + this.itemClickListener = itemClickListener; showCaption = true; } @@ -203,6 +208,11 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte this.binding = binding; + itemView.setOnLongClickListener(v -> { + itemClickListener.OnItemLongClick(galleryImages.get(getBindingAdapterPosition())); + return true; + }); + if (typeface != null) { binding.errorTextViewItemGalleryImageInPostFeed.setTypeface(typeface); } @@ -216,4 +226,8 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte }); } } + + public interface ItemClickListener { + void OnItemLongClick(Post.Gallery galleryImage); + } } 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 fadba1a5..a2f523e8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -3233,6 +3233,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter itemView.performLongClick()); + loadImageErrorTextView.setOnClickListener(view -> { progressBar.setVisibility(View.VISIBLE); loadImageErrorTextView.setVisibility(View.GONE); @@ -3243,6 +3245,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter itemView.performLongClick()); + glideRequestListener = new RequestListener<>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { @@ -3339,7 +3343,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter itemView.performLongClick()); galleryRecyclerView.setAdapter(adapter); galleryRecyclerView.setOnTouchListener((v, motionEvent) -> { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) { @@ -3439,6 +3444,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter itemView.performLongClick()); } public boolean isSwipeLocked() { @@ -4027,7 +4034,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter {}); recyclerView.setOnTouchListener((v, motionEvent) -> { if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) { if (mActivity.mSliderPanel != null) { -- cgit v1.2.3