Skip to content

Commit

Permalink
Long click the preview image to open PostOptionsBottomSheetFragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Sep 28, 2024
1 parent b7e63c0 commit d2c240d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3656,7 +3656,8 @@ public class PostBaseGalleryTypeViewHolder extends PostBaseViewHolder {
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);

adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
galleryImage -> itemView.performLongClick());
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) {
Expand Down Expand Up @@ -4613,7 +4614,8 @@ public PostGalleryBaseGalleryTypeViewHolder(@NonNull View itemView,
imageIndexTextView.setBorderColor(mMediaIndicatorBackgroundColor);

adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
galleryImage -> {});
recyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) {
Expand Down Expand Up @@ -6235,7 +6237,8 @@ public class PostMaterial3CardBaseGalleryTypeViewHolder extends PostMaterial3Car
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);

adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
galleryImage -> itemView.performLongClick());
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,8 @@ class PostDetailGalleryViewHolder extends PostDetailBaseViewHolder {

adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface, mPostDetailMarkwon,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor,
mCardViewColor, mCommentColor, mScale);
mCardViewColor, mCommentColor, mScale,
galleryImage -> {});
binding.galleryRecyclerViewItemPostDetailGallery.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(binding.galleryRecyclerViewItemPostDetailGallery);
binding.galleryRecyclerViewItemPostDetailGallery.setOnTouchListener((v, motionEvent) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -70,6 +74,7 @@ public PostGalleryTypeImageRecyclerViewAdapter(RequestManager glide, Typeface ty
this.mCardViewColor = mCardViewColor;
this.mCommentColor = mCommentColor;
this.mScale = scale;
this.itemClickListener = itemClickListener;
showCaption = true;
}

Expand Down Expand Up @@ -203,6 +208,11 @@ public ImageViewHolder(ItemGalleryImageInPostFeedBinding binding) {

this.binding = binding;

itemView.setOnLongClickListener(v -> {
itemClickListener.OnItemLongClick(galleryImages.get(getBindingAdapterPosition()));
return true;
});

if (typeface != null) {
binding.errorTextViewItemGalleryImageInPostFeed.setTypeface(typeface);
}
Expand All @@ -216,4 +226,8 @@ public ImageViewHolder(ItemGalleryImageInPostFeedBinding binding) {
});
}
}

public interface ItemClickListener {
void OnItemLongClick(Post.Gallery galleryImage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3233,6 +3233,8 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
}
});

imageView.setOnLongClickListener(view -> itemView.performLongClick());

loadImageErrorTextView.setOnClickListener(view -> {
progressBar.setVisibility(View.VISIBLE);
loadImageErrorTextView.setVisibility(View.GONE);
Expand All @@ -3243,6 +3245,8 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
imageView.performClick();
});

imageViewNoPreviewGallery.setOnLongClickListener(view -> itemView.performLongClick());

glideRequestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
Expand Down Expand Up @@ -3339,7 +3343,8 @@ public abstract class PostBaseGalleryTypeViewHolder extends PostBaseViewHolder {
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);

adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
galleryImage -> itemView.performLongClick());
galleryRecyclerView.setAdapter(adapter);
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
Expand Down Expand Up @@ -3439,6 +3444,8 @@ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
openMedia(post, 0);
}
});

noPreviewImageView.setOnLongClickListener(view -> itemView.performLongClick());
}

public boolean isSwipeLocked() {
Expand Down Expand Up @@ -4027,7 +4034,8 @@ public PostGalleryBaseGalleryTypeViewHolder(@NonNull View itemView,
imageIndexTextView.setBorderColor(mMediaIndicatorBackgroundColor);

adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
galleryImage -> {});
recyclerView.setOnTouchListener((v, motionEvent) -> {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
if (mActivity.mSliderPanel != null) {
Expand Down

0 comments on commit d2c240d

Please sign in to comment.