|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
package com.ortiz.touch;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.annotation.TargetApi;
|
|
|
import android.content.Context;
|
|
|
import android.content.res.Configuration;
|
|
@@ -38,6 +39,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.OverScroller;
|
|
|
import android.widget.Scroller;
|
|
|
|
|
|
+@SuppressLint("AppCompatCustomView")
|
|
|
public class TouchImageView extends ImageView {
|
|
|
|
|
|
private static final String DEBUG = "DEBUG";
|
|
@@ -94,9 +96,9 @@ public class TouchImageView extends ImageView {
|
|
|
|
|
|
private ScaleGestureDetector mScaleDetector;
|
|
|
private GestureDetector mGestureDetector;
|
|
|
- private GestureDetector.OnDoubleTapListener doubleTapListener = null;
|
|
|
+ private GestureDetector.OnDoubleTapListener doubleTapListener = null;
|
|
|
private OnTouchListener userTouchListener = null;
|
|
|
- private OnTouchImageViewListener touchImageViewListener = null;
|
|
|
+ private OnTouchImageViewListener touchImageViewListener = null;
|
|
|
|
|
|
public TouchImageView(Context context) {
|
|
|
super(context);
|
|
@@ -133,22 +135,22 @@ public class TouchImageView extends ImageView {
|
|
|
setScaleType(ScaleType.MATRIX);
|
|
|
setState(State.NONE);
|
|
|
onDrawReady = false;
|
|
|
- super.setOnTouchListener(new PrivateOnTouchListener());
|
|
|
+ super.setOnTouchListener(new PrivateOnTouchListener());
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setOnTouchListener(View.OnTouchListener l) {
|
|
|
- userTouchListener = l;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setOnTouchListener(View.OnTouchListener l) {
|
|
|
+ userTouchListener = l;
|
|
|
}
|
|
|
|
|
|
public void setOnTouchImageViewListener(OnTouchImageViewListener l) {
|
|
|
touchImageViewListener = l;
|
|
|
- }
|
|
|
-
|
|
|
- public void setOnDoubleTapListener(GestureDetector.OnDoubleTapListener l) {
|
|
|
- doubleTapListener = l;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setOnDoubleTapListener(GestureDetector.OnDoubleTapListener l) {
|
|
|
+ doubleTapListener = l;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void setImageResource(int resId) {
|
|
|
super.setImageResource(resId);
|
|
@@ -401,7 +403,7 @@ public class TouchImageView extends ImageView {
|
|
|
/**
|
|
|
* Set zoom parameters equal to another TouchImageView. Including scale, position,
|
|
|
* and ScaleType.
|
|
|
- * @param TouchImageView
|
|
|
+ * @param img
|
|
|
*/
|
|
|
public void setZoom(TouchImageView img) {
|
|
|
PointF center = img.getScrollPosition();
|
|
@@ -755,7 +757,7 @@ public class TouchImageView extends ImageView {
|
|
|
{
|
|
|
if(doubleTapListener != null) {
|
|
|
return doubleTapListener.onSingleTapConfirmed(e);
|
|
|
- }
|
|
|
+ }
|
|
|
return performClick();
|
|
|
}
|
|
|
|
|
@@ -785,7 +787,7 @@ public class TouchImageView extends ImageView {
|
|
|
boolean consumed = false;
|
|
|
if(doubleTapListener != null) {
|
|
|
consumed = doubleTapListener.onDoubleTap(e);
|
|
|
- }
|
|
|
+ }
|
|
|
if (state == State.NONE) {
|
|
|
float targetZoom = (normalizedScale == minScale) ? maxScale : minScale;
|
|
|
DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, e.getX(), e.getY(), false);
|
|
@@ -794,14 +796,14 @@ public class TouchImageView extends ImageView {
|
|
|
}
|
|
|
return consumed;
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onDoubleTapEvent(MotionEvent e) {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onDoubleTapEvent(MotionEvent e) {
|
|
|
if(doubleTapListener != null) {
|
|
|
return doubleTapListener.onDoubleTapEvent(e);
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public interface OnTouchImageViewListener {
|