add a simple gesture detector for future zooming

This commit is contained in:
tibbi 2016-08-26 23:45:27 +02:00
parent 2a11b98a17
commit e31bee7780
1 changed files with 14 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import android.net.Uri;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@ -48,6 +49,7 @@ public class Preview extends ViewGroup
private static Point mScreenSize;
private static Uri mTargetUri;
private static Context mContext;
private static ScaleGestureDetector mScaleGestureDetector;
private static boolean mCanTakePicture;
private static boolean mIsFlashEnabled;
@ -86,6 +88,7 @@ public class Preview extends ViewGroup
mCurVideoPath = "";
mScreenSize = Utils.getScreenSize(mActivity);
mContext = getContext();
initGestureDetector();
}
public void trySwitchToVideo() {
@ -158,6 +161,16 @@ public class Preview extends ViewGroup
mTargetUri = uri;
}
private void initGestureDetector() {
mScaleGestureDetector = new ScaleGestureDetector(mContext, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {
final float factor = detector.getScaleFactor();
return super.onScale(detector);
}
});
}
private static int getPreviewRotation(int cameraId) {
final Camera.CameraInfo info = Utils.getCameraInfo(cameraId);
final int degrees = getRotationDegrees();
@ -542,6 +555,7 @@ public class Preview extends ViewGroup
public boolean onTouch(View v, MotionEvent event) {
mLastClickX = (int) event.getX();
mLastClickY = (int) event.getY();
mScaleGestureDetector.onTouchEvent(event);
return false;
}