package com.draw.painting.canvas.core;

import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

/* loaded from: classes.dex */
public class ImageGestureController implements View.OnTouchListener {
    private static final int DRAG = 1;
    private static final int NONE = 0;
    private static final int ZOOM = 2;
    private float k;
    ImageView view;
    float[] lastEvent = null;
    float d = 1.0f;
    float newRot = 0.0f;
    private Matrix matrix = new Matrix();
    private Matrix savedMatrix = new Matrix();
    private PointF start = new PointF();
    private PointF mid = new PointF();
    float oldDist = 1.0f;
    private int mode = 0;

    public ImageGestureController(ImageView imageview, float ScaleW, float ScaleH, float x, float y) {
        this.view = imageview;
        Log.e("Pos..........", String.valueOf(x) + "..............." + String.valueOf(y));
        this.matrix.postScale(ScaleW, ScaleH, this.mid.x, this.mid.y);
        this.matrix.postTranslate(x, y);
        this.view.setImageMatrix(this.matrix);
    }

    private float a(MotionEvent paramMotionEvent) {
        float x = paramMotionEvent.getX(0) - paramMotionEvent.getX(1);
        float y = paramMotionEvent.getY(0) - paramMotionEvent.getY(1);
        return (float) Math.sqrt((x * x) + (y * y));
    }

    private void a(PointF paramPointF, MotionEvent paramMotionEvent) {
        paramPointF.set((paramMotionEvent.getX(0) + paramMotionEvent.getX(1)) / 2.0f, (paramMotionEvent.getY(0) + paramMotionEvent.getY(1)) / 2.0f);
    }

    private float b(MotionEvent paramMotionEvent) {
        return (float) Math.toDegrees(Math.atan2(paramMotionEvent.getY(0) - paramMotionEvent.getY(1), paramMotionEvent.getX(0) - paramMotionEvent.getX(1)));
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0016, code lost:
        if (r7 != 6) goto L11;
     */
    @Override // android.view.View.OnTouchListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public boolean onTouch(View r7, MotionEvent r8) {
        /*
            Method dump skipped, instructions count: 240
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.draw.painting.canvas.core.ImageGestureController.onTouch(android.view.View, android.view.MotionEvent):boolean");
    }

    private float rotation(MotionEvent event) {
        return (float) Math.toDegrees(Math.atan2(event.getY(0) - event.getY(1), event.getX(0) - event.getX(1)));
    }

    private float spacing(MotionEvent event) {
        float x = event.getX(0) - event.getX(1);
        float y = event.getY(0) - event.getY(1);
        return (float) Math.sqrt((x * x) + (y * y));
    }

    private void midPoint(PointF point, MotionEvent event) {
        point.set((event.getX(0) + event.getX(1)) / 2.0f, (event.getY(0) + event.getY(1)) / 2.0f);
    }
}

