From 3ac91b4c1ee85746804849efe44abf6c8dc4dda4 Mon Sep 17 00:00:00 2001 From: "353162434@qq.com" Date: Mon, 29 Aug 2022 17:29:29 +0800 Subject: [PATCH] =?UTF-8?q?SubsamplingScaleImageView=20=E9=95=BF=E6=8C=89?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=9B=BF=E6=8D=A2=20onLongClick->onLongPress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xpopup/util/SmartGlideImageLoader.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/library/src/main/java/com/lxj/xpopup/util/SmartGlideImageLoader.java b/library/src/main/java/com/lxj/xpopup/util/SmartGlideImageLoader.java index aa09ff62..552425e8 100644 --- a/library/src/main/java/com/lxj/xpopup/util/SmartGlideImageLoader.java +++ b/library/src/main/java/com/lxj/xpopup/util/SmartGlideImageLoader.java @@ -7,14 +7,14 @@ import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.util.Log; +import android.view.GestureDetector; +import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.ProgressBar; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.bumptech.glide.Glide; -import com.bumptech.glide.load.resource.bitmap.Rotate; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; @@ -140,12 +140,27 @@ public void onClick(View v) { } }); if (popupView.longPressListener != null) { - ssiv.setOnLongClickListener(new View.OnLongClickListener() { + GestureDetector mGestureDetector = new GestureDetector(popupView.getContext(), new GestureDetector.SimpleOnGestureListener() { @Override - public boolean onLongClick(View v) { - popupView.longPressListener.onLongPressed(popupView, realPosition); - return false; + public void onLongPress(MotionEvent e) { + if (popupView.longPressListener != null) { + popupView.longPressListener.onLongPressed(popupView, realPosition); + } + } + }); + + ssiv.setOnTouchListener((v, ev) -> { + switch (ev.getAction()) { + case MotionEvent.ACTION_DOWN: + if (v != null) { + v.getParent().requestDisallowInterceptTouchEvent(true); + } + break; + } + if (mGestureDetector != null && mGestureDetector.onTouchEvent(ev)) { + return true; } + return false; }); } return ssiv;