Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to cancel long click #555

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public SubsamplingScaleImageView(Context context, AttributeSet attr) {
setGestureDetector(context);
this.handler = new Handler(new Handler.Callback() {
public boolean handleMessage(Message message) {
if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null) {
if (message.what == MESSAGE_LONG_CLICK && onLongClickListener != null && isLongClickable()) {
maxTouchCount = 0;
SubsamplingScaleImageView.super.setOnLongClickListener(onLongClickListener);
performLongClick();
Expand Down Expand Up @@ -922,6 +922,13 @@ private boolean onTouchEventInternal(@NonNull MotionEvent event) {
maxTouchCount = 0;
}
return true;
case MotionEvent.ACTION_CANCEL:
handler.removeMessages(MESSAGE_LONG_CLICK);
isQuickScaling = false;
isZooming = false;
isPanning = false;
maxTouchCount = 0;
return true;
}
return false;
}
Expand Down Expand Up @@ -2856,6 +2863,9 @@ public boolean hasImage() {
*/
@Override
public void setOnLongClickListener(OnLongClickListener onLongClickListener) {
if (!isLongClickable()) {
setLongClickable(true);
}
this.onLongClickListener = onLongClickListener;
}

Expand Down