Skip to content
Open
Show file tree
Hide file tree
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
@@ -0,0 +1,10 @@
package com.github.chrisbanes.photoview;

import android.view.MotionEvent;
import android.view.View;

public interface AdditionalOnTouchListener {

boolean onTouch (View view, MotionEvent event);

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public class PhotoViewAttacher implements View.OnTouchListener,
private boolean mZoomEnabled = true;
private ScaleType mScaleType = ScaleType.FIT_CENTER;


//For adding our own onTouchListener
private AdditionalOnTouchListener mAdditionalOnTouchListener;

private OnGestureListener onGestureListener = new OnGestureListener() {
@Override
public void onDrag(float dx, float dy) {
Expand Down Expand Up @@ -332,6 +336,10 @@ public ScaleType getScaleType() {
return mScaleType;
}

public void setAdditionalOnTouchListener (AdditionalOnTouchListener listener) {
this.mAdditionalOnTouchListener = listener;
}

@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
// Update our base matrix, as the bounds have changed
Expand All @@ -342,6 +350,15 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int

@Override
public boolean onTouch(View v, MotionEvent ev) {

if (mAdditionalOnTouchListener != null) {
if (mAdditionalOnTouchListener.onTouch(v, ev)) { //It consumed
return true;
} else {
//Continue
}
}

boolean handled = false;

if (mZoomEnabled && Util.hasDrawable((ImageView) v)) {
Expand Down