content: package com.example.vault.photo.util;
  
  import android.annotation.TargetApi;
  import android.content.Context;
  import android.content.res.Configuration;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Matrix;
  import android.graphics.PointF;
  import android.graphics.RectF;
  import android.graphics.drawable.Drawable;
  import android.net.Uri;
  import android.os.Build.VERSION;
  import android.os.Bundle;
  import android.os.Parcelable;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.GestureDetector;
  import android.view.GestureDetector.OnDoubleTapListener;
  import android.view.GestureDetector.SimpleOnGestureListener;
  import android.view.MotionEvent;
  import android.view.ScaleGestureDetector;
  import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
  import android.view.View;
  import android.view.animation.AccelerateDecelerateInterpolator;
  import android.widget.OverScroller;
  import android.widget.Scroller;
  
  public class TouchImageViewNew extends androidx.appcompat.widget.AppCompatImageView {
      private static final String DEBUG = "DEBUG";
      private static final float SUPER_MAX_MULTIPLIER = 1.25f;
      private static final float SUPER_MIN_MULTIPLIER = 0.75f;
  
      public Context context;
      private ZoomVariables delayedZoomVariables;
  
      public OnDoubleTapListener doubleTapListener = null;
  
      public Fling fling;
      private boolean imageRenderedAtLeastOnce;
  
      public float[] m;
  
      public GestureDetector mGestureDetector;
  
      public ScaleGestureDetector mScaleDetector;
      private ScaleType mScaleType;
      private float matchViewHeight;
      private float matchViewWidth;
  
      public Matrix matrix;
  
      public float maxScale;
  
      public float minScale;
  
      public float normalizedScale;
      private boolean onDrawReady;
      private float prevMatchViewHeight;
      private float prevMatchViewWidth;
      private Matrix prevMatrix;
      private int prevViewHeight;
      private int prevViewWidth;
  
      public State state;
      private float superMaxScale;
      private float superMinScale;
  
      public OnTouchImageViewListener touchImageViewListener = null;
  
      public OnTouchListener userTouchListener = null;
  
      public int viewHeight;
  
      public int viewWidth;
  
  
      static /* synthetic */ class AnonymousClass1 {
          static final /* synthetic */ int[] $SwitchMap$android$widget$ImageView$ScaleType = new int[ScaleType.values().length];
  
  
          static {
              $SwitchMap$android$widget$ImageView$ScaleType[ScaleType.CENTER.ordinal()] = 1;
              $SwitchMap$android$widget$ImageView$ScaleType[ScaleType.CENTER_CROP.ordinal()] = 2;
              $SwitchMap$android$widget$ImageView$ScaleType[ScaleType.CENTER_INSIDE.ordinal()] = 3;
              $SwitchMap$android$widget$ImageView$ScaleType[ScaleType.FIT_CENTER.ordinal()] = 4;
              $SwitchMap$android$widget$ImageView$ScaleType[ScaleType.FIT_XY.ordinal()] = 5;
          }
      }
  
      @TargetApi(9)
      private class CompatScroller {
          boolean isPreGingerbread;
          OverScroller overScroller;
          Scroller scroller;
  
          public CompatScroller(Context context) {
              if (VERSION.SDK_INT < 9) {
                  this.isPreGingerbread = true;
                  this.scroller = new Scroller(context);
                  return;
              }
              this.isPreGingerbread = false;
              this.overScroller = new OverScroller(context);
          }
  
          public void fling(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
              if (this.isPreGingerbread) {
                  this.scroller.fling(i, i2, i3, i4, i5, i6, i7, i8);
              } else {
                  this.overScroller.fling(i, i2, i3, i4, i5, i6, i7, i8);
              }
          }
  
          public void forceFinished(boolean z) {
              if (this.isPreGingerbread) {
                  this.scroller.forceFinished(z);
              } else {
                  this.overScroller.forceFinished(z);
              }
          }
  
          public boolean isFinished() {
              if (this.isPreGingerbread) {
                  return this.scroller.isFinished();
              }
              return this.overScroller.isFinished();
          }
  
          public boolean computeScrollOffset() {
              if (this.isPreGingerbread) {
                  return this.scroller.computeScrollOffset();
              }
              this.overScroller.computeScrollOffset();
              return this.overScroller.computeScrollOffset();
          }
  
          public int getCurrX() {
              if (this.isPreGingerbread) {
                  return this.scroller.getCurrX();
              }
              return this.overScroller.getCurrX();
          }
  
          public int getCurrY() {
              if (this.isPreGingerbread) {
                  return this.scroller.getCurrY();
              }
              return this.overScroller.getCurrY();
          }
      }
  
      private class DoubleTapZoom implements Runnable {
          private static final float ZOOM_TIME = 500.0f;
          private float bitmapX;
          private float bitmapY;
          private PointF endTouch;
          private AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator();
          private long startTime;
          private PointF startTouch;
          private float startZoom;
          private boolean stretchImageToSuper;
          private float targetZoom;
  
          DoubleTapZoom(float f, float f2, float f3, boolean z) {
              TouchImageViewNew.this.setState(State.ANIMATE_ZOOM);
              this.startTime = System.currentTimeMillis();
              this.startZoom = TouchImageViewNew.this.normalizedScale;
              this.targetZoom = f;
              this.stretchImageToSuper = z;
              PointF access$2300 = TouchImageViewNew.this.transformCoordTouchToBitmap(f2, f3, false);
              this.bitmapX = access$2300.x;
              this.bitmapY = access$2300.y;
              this.startTouch = TouchImageViewNew.this.transformCoordBitmapToTouch(this.bitmapX, this.bitmapY);
              this.endTouch = new PointF((float) (TouchImageViewNew.this.viewWidth / 2), (float) (TouchImageViewNew.this.viewHeight / 2));
          }
  
          public void run() {
              float interpolate = interpolate();
              TouchImageViewNew.this.scaleImage(calculateDeltaScale(interpolate), this.bitmapX, this.bitmapY, this.stretchImageToSuper);
              translateImageToCenterTouchPosition(interpolate);
              TouchImageViewNew.this.fixScaleTrans();
              TouchImageViewNew touchImageViewNew = TouchImageViewNew.this;
              touchImageViewNew.setImageMatrix(touchImageViewNew.matrix);
              if (TouchImageViewNew.this.touchImageViewListener != null) {
                  TouchImageViewNew.this.touchImageViewListener.onMove();
              }
              if (interpolate < 1.0f) {
                  TouchImageViewNew.this.compatPostOnAnimation(this);
              } else {
                  TouchImageViewNew.this.setState(State.NONE);
              }
          }
  
          private void translateImageToCenterTouchPosition(float f) {
              float f2 = this.startTouch.x + ((this.endTouch.x - this.startTouch.x) * f);
              float f3 = this.startTouch.y + (f * (this.endTouch.y - this.startTouch.y));
              PointF access$2400 = TouchImageViewNew.this.transformCoordBitmapToTouch(this.bitmapX, this.bitmapY);
              TouchImageViewNew.this.matrix.postTranslate(f2 - access$2400.x, f3 - access$2400.y);
          }
  
          private float interpolate() {
              return this.interpolator.getInterpolation(Math.min(1.0f, ((float) (System.currentTimeMillis() - this.startTime)) / ZOOM_TIME));
          }
  
          private double calculateDeltaScale(float f) {
              float f2 = this.startZoom;
              double d = (double) (f2 + (f * (this.targetZoom - f2)));
              double access$700 = (double) TouchImageViewNew.this.normalizedScale;
              Double.isNaN(d);
              Double.isNaN(access$700);
              return d / access$700;
          }
      }
  
      private class Fling implements Runnable {
          int currX;
          int currY;
          CompatScroller scroller;
  
          Fling(int i, int i2) {
              int i3;
              int i4;
              int i5;
              int i6;
              TouchImageViewNew.this.setState(State.FLING);
              this.scroller = new CompatScroller(TouchImageViewNew.this.context);
              TouchImageViewNew.this.matrix.getValues(TouchImageViewNew.this.m);
              int i7 = (int) TouchImageViewNew.this.m[2];
              int i8 = (int) TouchImageViewNew.this.m[5];
              if (TouchImageViewNew.this.getImageWidth() > ((float) TouchImageViewNew.this.viewWidth)) {
                  i4 = TouchImageViewNew.this.viewWidth - ((int) TouchImageViewNew.this.getImageWidth());
                  i3 = 0;
              } else {
                  i4 = i7;
                  i3 = i4;
              }
              if (TouchImageViewNew.this.getImageHeight() > ((float) TouchImageViewNew.this.viewHeight)) {
                  i6 = TouchImageViewNew.this.viewHeight - ((int) TouchImageViewNew.this.getImageHeight());
                  i5 = 0;
              } else {
                  i6 = i8;
                  i5 = i6;
              }
              this.scroller.fling(i7, i8, i, i2, i4, i3, i6, i5);
              this.currX = i7;
              this.currY = i8;
          }
  
          public void cancelFling() {
              if (this.scroller != null) {
                  TouchImageViewNew.this.setState(State.NONE);
                  this.scroller.forceFinished(true);
              }
          }
  
          public void run() {
              if (TouchImageViewNew.this.touchImageViewListener != null) {
                  TouchImageViewNew.this.touchImageViewListener.onMove();
              }
              if (this.scroller.isFinished()) {
                  this.scroller = null;
                  return;
              }
              if (this.scroller.computeScrollOffset()) {
                  int currX2 = this.scroller.getCurrX();
                  int currY2 = this.scroller.getCurrY();
                  int i = currX2 - this.currX;
                  int i2 = currY2 - this.currY;
                  this.currX = currX2;
                  this.currY = currY2;
                  TouchImageViewNew.this.matrix.postTranslate((float) i, (float) i2);
                  TouchImageViewNew.this.fixTrans();
                  TouchImageViewNew touchImageViewNew = TouchImageViewNew.this;
                  touchImageViewNew.setImageMatrix(touchImageViewNew.matrix);
                  TouchImageViewNew.this.compatPostOnAnimation(this);
              }
          }
      }
  
      private class GestureListener extends SimpleOnGestureListener {
          private GestureListener() {
          }
  
          /* synthetic */ GestureListener(TouchImageViewNew touchImageViewNew, AnonymousClass1 r2) {
              this();
          }
  
          public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
              if (TouchImageViewNew.this.doubleTapListener != null) {
                  return TouchImageViewNew.this.doubleTapListener.onSingleTapConfirmed(motionEvent);
              }
              return TouchImageViewNew.this.performClick();
          }
  
          public void onLongPress(MotionEvent motionEvent) {
              TouchImageViewNew.this.performLongClick();
          }
  
          public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
              if (TouchImageViewNew.this.fling != null) {
                  TouchImageViewNew.this.fling.cancelFling();
              }
              TouchImageViewNew touchImageViewNew = TouchImageViewNew.this;
              touchImageViewNew.fling = new Fling((int) f, (int) f2);
              TouchImageViewNew touchImageViewNew2 = TouchImageViewNew.this;
              touchImageViewNew2.compatPostOnAnimation(touchImageViewNew2.fling);
              return super.onFling(motionEvent, motionEvent2, f, f2);
          }
  
          public boolean onDoubleTap(MotionEvent motionEvent) {
              boolean onDoubleTap = TouchImageViewNew.this.doubleTapListener != null ? TouchImageViewNew.this.doubleTapListener.onDoubleTap(motionEvent) : false;
              if (TouchImageViewNew.this.state != State.NONE) {
                  return onDoubleTap;
              }
              DoubleTapZoom doubleTapZoom = new DoubleTapZoom(TouchImageViewNew.this.normalizedScale == TouchImageViewNew.this.minScale ? TouchImageViewNew.this.maxScale : TouchImageViewNew.this.minScale, motionEvent.getX(), motionEvent.getY(), false);
              TouchImageViewNew.this.compatPostOnAnimation(doubleTapZoom);
              return true;
          }
  
          public boolean onDoubleTapEvent(MotionEvent motionEvent) {
              if (TouchImageViewNew.this.doubleTapListener != null) {
                  return TouchImageViewNew.this.doubleTapListener.onDoubleTapEvent(motionEvent);
              }
              return false;
          }
      }
  
      public interface OnTouchImageViewListener {
          void onMove();
      }
  
      private class PrivateOnTouchListener implements OnTouchListener {
          private PointF last;
  
          private PrivateOnTouchListener() {
              this.last = new PointF();
          }
  
          /* synthetic */ PrivateOnTouchListener(TouchImageViewNew touchImageViewNew, AnonymousClass1 r2) {
              this();
          }
  
          public boolean onTouch(View view, MotionEvent motionEvent) {
              TouchImageViewNew.this.mScaleDetector.onTouchEvent(motionEvent);
              TouchImageViewNew.this.mGestureDetector.onTouchEvent(motionEvent);
              PointF pointF = new PointF(motionEvent.getX(), motionEvent.getY());
              if (TouchImageViewNew.this.state == State.NONE || TouchImageViewNew.this.state == State.DRAG || TouchImageViewNew.this.state == State.FLING) {
                  int action = motionEvent.getAction();
                  if (action != 6) {
                      switch (action) {
                          case 0:
                              this.last.set(pointF);
                              if (TouchImageViewNew.this.fling != null) {
                                  TouchImageViewNew.this.fling.cancelFling();
                              }
                              TouchImageViewNew.this.setState(State.DRAG);
                              break;
                          case 1:
                              break;
                          case 2:
                              if (TouchImageViewNew.this.state == State.DRAG) {
                                  float f = pointF.x - this.last.x;
                                  float f2 = pointF.y - this.last.y;
                                  TouchImageViewNew touchImageViewNew = TouchImageViewNew.this;
                                  float access$1500 = touchImageViewNew.getFixDragTrans(f, (float) touchImageViewNew.viewWidth, TouchImageViewNew.this.getImageWidth());
                                  TouchImageViewNew touchImageViewNew2 = TouchImageViewNew.this;
                                  TouchImageViewNew.this.matrix.postTranslate(access$1500, touchImageViewNew2.getFixDragTrans(f2, (float) touchImageViewNew2.viewHeight, TouchImageViewNew.this.getImageHeight()));
                                  TouchImageViewNew.this.fixTrans();
                                  this.last.set(pointF.x, pointF.y);
                                  break;
                              }
                              break;
                      }
                  }
                  TouchImageViewNew.this.setState(State.NONE);
              }
              TouchImageViewNew touchImageViewNew3 = TouchImageViewNew.this;
              touchImageViewNew3.setImageMatrix(touchImageViewNew3.matrix);
              if (TouchImageViewNew.this.userTouchListener != null) {
                  TouchImageViewNew.this.userTouchListener.onTouch(view, motionEvent);
              }
              if (TouchImageViewNew.this.touchImageViewListener != null) {
                  TouchImageViewNew.this.touchImageViewListener.onMove();
              }
              return true;
          }
      }
  
      private class ScaleListener extends SimpleOnScaleGestureListener {
          private ScaleListener() {
          }
  
          /* synthetic */ ScaleListener(TouchImageViewNew touchImageViewNew, AnonymousClass1 r2) {
              this();
          }
  
          public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
              TouchImageViewNew.this.setState(State.ZOOM);
              return true;
          }
  
          public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
              TouchImageViewNew.this.scaleImage((double) scaleGestureDetector.getScaleFactor(), scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY(), true);
              if (TouchImageViewNew.this.touchImageViewListener != null) {
                  TouchImageViewNew.this.touchImageViewListener.onMove();
              }
              return true;
          }
  
          public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) {
              float f;
              super.onScaleEnd(scaleGestureDetector);
              TouchImageViewNew.this.setState(State.NONE);
              float access$700 = TouchImageViewNew.this.normalizedScale;
              boolean z = true;
              if (TouchImageViewNew.this.normalizedScale > TouchImageViewNew.this.maxScale) {
                  f = TouchImageViewNew.this.maxScale;
              } else if (TouchImageViewNew.this.normalizedScale < TouchImageViewNew.this.minScale) {
                  f = TouchImageViewNew.this.minScale;
              } else {
                  z = false;
                  f = access$700;
              }
              if (z) {
                  TouchImageViewNew touchImageViewNew = TouchImageViewNew.this;
                  DoubleTapZoom doubleTapZoom = new DoubleTapZoom(f, (float) (touchImageViewNew.viewWidth / 2), (float) (TouchImageViewNew.this.viewHeight / 2), true);
                  TouchImageViewNew.this.compatPostOnAnimation(doubleTapZoom);
              }
          }
      }
  
      private enum State {
          NONE,
          DRAG,
          ZOOM,
          FLING,
          ANIMATE_ZOOM
      }
  
      private class ZoomVariables {
          public float focusX;
          public float focusY;
          public float scale;
          public ScaleType scaleType;
  
          public ZoomVariables(float f, float f2, float f3, ScaleType scaleType2) {
              this.scale = f;
              this.focusX = f2;
              this.focusY = f3;
              this.scaleType = scaleType2;
          }
      }
  
  
      public float getFixDragTrans(float f, float f2, float f3) {
          if (f3 <= f2) {
              return 0.0f;
          }
          return f;
      }
  
      private float getFixTrans(float f, float f2, float f3) {
          float f4;
          float f5;
          if (f3 <= f2) {
              f4 = f2 - f3;
              f5 = 0.0f;
          } else {
              f5 = f2 - f3;
              f4 = 0.0f;
          }
          if (f < f5) {
              return (-f) + f5;
          }
          if (f > f4) {
              return (-f) + f4;
          }
          return 0.0f;
      }
  
      public TouchImageViewNew(Context context2) {
          super(context2);
          sharedConstructing(context2);
      }
  
      public TouchImageViewNew(Context context2, AttributeSet attributeSet) {
          super(context2, attributeSet);
          sharedConstructing(context2);
      }
  
      public TouchImageViewNew(Context context2, AttributeSet attributeSet, int i) {
          super(context2, attributeSet, i);
          sharedConstructing(context2);
      }
  
      private void sharedConstructing(Context context2) {
          super.setClickable(true);
          this.context = context2;
          this.mScaleDetector = new ScaleGestureDetector(context2, new ScaleListener(this, null));
          this.mGestureDetector = new GestureDetector(context2, new GestureListener(this, null));
          this.matrix = new Matrix();
          this.prevMatrix = new Matrix();
          this.m = new float[9];
          this.normalizedScale = 1.0f;
          if (this.mScaleType == null) {
              this.mScaleType = ScaleType.FIT_CENTER;
          }
          this.minScale = 1.0f;
          this.maxScale = 3.0f;
          this.superMinScale = this.minScale * SUPER_MIN_MULTIPLIER;
          this.superMaxScale = this.maxScale * SUPER_MAX_MULTIPLIER;
          setImageMatrix(this.matrix);
          setScaleType(ScaleType.MATRIX);
          setState(State.NONE);
          this.onDrawReady = false;
          super.setOnTouchListener(new PrivateOnTouchListener(this, null));
      }
  
      public void setOnTouchListener(OnTouchListener onTouchListener) {
          this.userTouchListener = onTouchListener;
      }
  
      public void setOnTouchImageViewListener(OnTouchImageViewListener onTouchImageViewListener) {
          this.touchImageViewListener = onTouchImageViewListener;
      }
  
      public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
          this.doubleTapListener = onDoubleTapListener;
      }
  
      public void setImageResource(int i) {
          super.setImageResource(i);
          savePreviousImageValues();
          fitImageToView();
      }
  
      public void setImageBitmap(Bitmap bitmap) {
          super.setImageBitmap(bitmap);
          savePreviousImageValues();
          fitImageToView();
      }
  
      public void setImageDrawable(Drawable drawable) {
          super.setImageDrawable(drawable);
          savePreviousImageValues();
          fitImageToView();
      }
  
      public void setImageURI(Uri uri) {
          super.setImageURI(uri);
          savePreviousImageValues();
          fitImageToView();
      }
  
      public void setScaleType(ScaleType scaleType) {
          if (scaleType == ScaleType.FIT_START || scaleType == ScaleType.FIT_END) {
              throw new UnsupportedOperationException("TouchImageView does not support FIT_START or FIT_END");
          } else if (scaleType == ScaleType.MATRIX) {
              super.setScaleType(ScaleType.MATRIX);
          } else {
              this.mScaleType = scaleType;
              if (this.onDrawReady) {
                  setZoom(this);
              }
          }
      }
  
      public ScaleType getScaleType() {
          return this.mScaleType;
      }
  
      public boolean isZoomed() {
          return this.normalizedScale != 1.0f;
      }
  
      public RectF getZoomedRect() {
          if (this.mScaleType != ScaleType.FIT_XY) {
              PointF transformCoordTouchToBitmap = transformCoordTouchToBitmap(0.0f, 0.0f, true);
              PointF transformCoordTouchToBitmap2 = transformCoordTouchToBitmap((float) this.viewWidth, (float) this.viewHeight, true);
              float intrinsicWidth = (float) getDrawable().getIntrinsicWidth();
              float intrinsicHeight = (float) getDrawable().getIntrinsicHeight();
              return new RectF(transformCoordTouchToBitmap.x / intrinsicWidth, transformCoordTouchToBitmap.y / intrinsicHeight, transformCoordTouchToBitmap2.x / intrinsicWidth, transformCoordTouchToBitmap2.y / intrinsicHeight);
          }
          throw new UnsupportedOperationException("getZoomedRect() not supported with FIT_XY");
      }
  
      private void savePreviousImageValues() {
          Matrix matrix2 = this.matrix;
          if (matrix2 != null && this.viewHeight != 0 && this.viewWidth != 0) {
              matrix2.getValues(this.m);
              this.prevMatrix.setValues(this.m);
              this.prevMatchViewHeight = this.matchViewHeight;
              this.prevMatchViewWidth = this.matchViewWidth;
              this.prevViewHeight = this.viewHeight;
              this.prevViewWidth = this.viewWidth;
          }
      }
  
      public Parcelable onSaveInstanceState() {
          Bundle bundle = new Bundle();
          bundle.putParcelable("instanceState", super.onSaveInstanceState());
          bundle.putFloat("saveScale", this.normalizedScale);
          bundle.putFloat("matchViewHeight", this.matchViewHeight);
          bundle.putFloat("matchViewWidth", this.matchViewWidth);
          bundle.putInt("viewWidth", this.viewWidth);
          bundle.putInt("viewHeight", this.viewHeight);
          this.matrix.getValues(this.m);
          bundle.putFloatArray("matrix", this.m);
          bundle.putBoolean("imageRendered", this.imageRenderedAtLeastOnce);
          return bundle;
      }
  
      public void onRestoreInstanceState(Parcelable parcelable) {
          if (parcelable instanceof Bundle) {
              Bundle bundle = (Bundle) parcelable;
              this.normalizedScale = bundle.getFloat("saveScale");
              this.m = bundle.getFloatArray("matrix");
              this.prevMatrix.setValues(this.m);
              this.prevMatchViewHeight = bundle.getFloat("matchViewHeight");
              this.prevMatchViewWidth = bundle.getFloat("matchViewWidth");
              this.prevViewHeight = bundle.getInt("viewHeight");
              this.prevViewWidth = bundle.getInt("viewWidth");
              this.imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
              super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
              return;
          }
          super.onRestoreInstanceState(parcelable);
      }
  
  
      public void onDraw(Canvas canvas) {
          this.onDrawReady = true;
          this.imageRenderedAtLeastOnce = true;
          ZoomVariables zoomVariables = this.delayedZoomVariables;
          if (zoomVariables != null) {
              setZoom(zoomVariables.scale, this.delayedZoomVariables.focusX, this.delayedZoomVariables.focusY, this.delayedZoomVariables.scaleType);
              this.delayedZoomVariables = null;
          }
          super.onDraw(canvas);
      }
  
      public void onConfigurationChanged(Configuration configuration) {
          super.onConfigurationChanged(configuration);
          savePreviousImageValues();
      }
  
      public float getMaxZoom() {
          return this.maxScale;
      }
  
      public void setMaxZoom(float f) {
          this.maxScale = f;
          this.superMaxScale = this.maxScale * SUPER_MAX_MULTIPLIER;
      }
  
      public float getMinZoom() {
          return this.minScale;
      }
  
      public float getCurrentZoom() {
          return this.normalizedScale;
      }
  
      public void setMinZoom(float f) {
          this.minScale = f;
          this.superMinScale = this.minScale * SUPER_MIN_MULTIPLIER;
      }
  
      public void resetZoom() {
          this.normalizedScale = 1.0f;
          fitImageToView();
      }
  
      public void setZoom(float f) {
          setZoom(f, 0.5f, 0.5f);
      }
  
      public void setZoom(float f, float f2, float f3) {
          setZoom(f, f2, f3, this.mScaleType);
      }
  
      public void setZoom(float f, float f2, float f3, ScaleType scaleType) {
          if (!this.onDrawReady) {
              ZoomVariables zoomVariables = new ZoomVariables(f, f2, f3, scaleType);
              this.delayedZoomVariables = zoomVariables;
              return;
          }
          if (scaleType != this.mScaleType) {
              setScaleType(scaleType);
          }
          resetZoom();
          scaleImage((double) f, (float) (this.viewWidth / 2), (float) (this.viewHeight / 2), true);
          this.matrix.getValues(this.m);
          this.m[2] = -((f2 * getImageWidth()) - (((float) this.viewWidth) * 0.5f));
          this.m[5] = -((f3 * getImageHeight()) - (((float) this.viewHeight) * 0.5f));
          this.matrix.setValues(this.m);
          fixTrans();
          setImageMatrix(this.matrix);
      }
  
      public void setZoom(TouchImageViewNew touchImageViewNew) {
          PointF scrollPosition = touchImageViewNew.getScrollPosition();
          setZoom(touchImageViewNew.getCurrentZoom(), scrollPosition.x, scrollPosition.y, touchImageViewNew.getScaleType());
      }
  
      public PointF getScrollPosition() {
          Drawable drawable = getDrawable();
          if (drawable == null) {
              return null;
          }
          int intrinsicWidth = drawable.getIntrinsicWidth();
          int intrinsicHeight = drawable.getIntrinsicHeight();
          PointF transformCoordTouchToBitmap = transformCoordTouchToBitmap((float) (this.viewWidth / 2), (float) (this.viewHeight / 2), true);
          transformCoordTouchToBitmap.x /= (float) intrinsicWidth;
          transformCoordTouchToBitmap.y /= (float) intrinsicHeight;
          return transformCoordTouchToBitmap;
      }
  
      public void setScrollPosition(float f, float f2) {
          setZoom(this.normalizedScale, f, f2);
      }
  
  
      public void fixTrans() {
          this.matrix.getValues(this.m);
          float[] fArr = this.m;
          float f = fArr[2];
          float f2 = fArr[5];
          float fixTrans = getFixTrans(f, (float) this.viewWidth, getImageWidth());
          float fixTrans2 = getFixTrans(f2, (float) this.viewHeight, getImageHeight());
          if (fixTrans != 0.0f || fixTrans2 != 0.0f) {
              this.matrix.postTranslate(fixTrans, fixTrans2);
          }
      }
  
  
      public void fixScaleTrans() {
          fixTrans();
          this.matrix.getValues(this.m);
          float imageWidth = getImageWidth();
          int i = this.viewWidth;
          if (imageWidth < ((float) i)) {
              this.m[2] = (((float) i) - getImageWidth()) / 2.0f;
          }
          float imageHeight = getImageHeight();
          int i2 = this.viewHeight;
          if (imageHeight < ((float) i2)) {
              this.m[5] = (((float) i2) - getImageHeight()) / 2.0f;
          }
          this.matrix.setValues(this.m);
      }
  
  
      public float getImageWidth() {
          return this.matchViewWidth * this.normalizedScale;
      }
  
  
      public float getImageHeight() {
          return this.matchViewHeight * this.normalizedScale;
      }
  
  
      public void onMeasure(int i, int i2) {
          Drawable drawable = getDrawable();
          if (drawable == null || drawable.getIntrinsicWidth() == 0 || drawable.getIntrinsicHeight() == 0) {
              setMeasuredDimension(0, 0);
              return;
          }
          int intrinsicWidth = drawable.getIntrinsicWidth();
          int intrinsicHeight = drawable.getIntrinsicHeight();
          int size = MeasureSpec.getSize(i);
          int mode = MeasureSpec.getMode(i);
          int size2 = MeasureSpec.getSize(i2);
          int mode2 = MeasureSpec.getMode(i2);
          this.viewWidth = setViewSize(mode, size, intrinsicWidth);
          this.viewHeight = setViewSize(mode2, size2, intrinsicHeight);
          setMeasuredDimension(this.viewWidth, this.viewHeight);
          fitImageToView();
      }
  
      private void fitImageToView() {
          Drawable drawable = getDrawable();
          if (drawable != null && drawable.getIntrinsicWidth() != 0 && drawable.getIntrinsicHeight() != 0 && this.matrix != null && this.prevMatrix != null) {
              int intrinsicWidth = drawable.getIntrinsicWidth();
              int intrinsicHeight = drawable.getIntrinsicHeight();
              float f = (float) intrinsicWidth;
              float f2 = ((float) this.viewWidth) / f;
              float f3 = (float) intrinsicHeight;
              float f4 = ((float) this.viewHeight) / f3;
              switch (AnonymousClass1.$SwitchMap$android$widget$ImageView$ScaleType[this.mScaleType.ordinal()]) {
                  case 1:
                      f2 = 1.0f;
                      f4 = 1.0f;
                      break;
                  case 2:
                      f2 = Math.max(f2, f4);
                      f4 = f2;
                      break;
                  case 3:
                      f2 = Math.min(1.0f, Math.min(f2, f4));
                      f4 = f2;
                      break;
                  case 4:
                      break;
                  case 5:
                      break;
                  default:
                      throw new UnsupportedOperationException("TouchImageView does not support FIT_START or FIT_END");
              }
              f2 = Math.min(f2, f4);
              f4 = f2;
              int i = this.viewWidth;
              float f5 = ((float) i) - (f2 * f);
              int i2 = this.viewHeight;
              float f6 = ((float) i2) - (f4 * f3);
              this.matchViewWidth = ((float) i) - f5;
              this.matchViewHeight = ((float) i2) - f6;
              if (isZoomed() || this.imageRenderedAtLeastOnce) {
                  if (this.prevMatchViewWidth == 0.0f || this.prevMatchViewHeight == 0.0f) {
                      savePreviousImageValues();
                  }
                  this.prevMatrix.getValues(this.m);
                  float[] fArr = this.m;
                  float f7 = this.matchViewWidth / f;
                  float f8 = this.normalizedScale;
                  fArr[0] = f7 * f8;
                  fArr[4] = (this.matchViewHeight / f3) * f8;
                  float f9 = fArr[2];
                  float f10 = fArr[5];
                  translateMatrixAfterRotate(2, f9, this.prevMatchViewWidth * f8, getImageWidth(), this.prevViewWidth, this.viewWidth, intrinsicWidth);
                  translateMatrixAfterRotate(5, f10, this.prevMatchViewHeight * this.normalizedScale, getImageHeight(), this.prevViewHeight, this.viewHeight, intrinsicHeight);
                  this.matrix.setValues(this.m);
              } else {
                  this.matrix.setScale(f2, f4);
                  this.matrix.postTranslate(f5 / 2.0f, f6 / 2.0f);
                  this.normalizedScale = 1.0f;
              }
              fixTrans();
              setImageMatrix(this.matrix);
          }
      }
  
      private int setViewSize(int i, int i2, int i3) {
          if (i != Integer.MIN_VALUE) {
              return i != 0 ? i2 : i3;
          }
          return Math.min(i3, i2);
      }
  
      private void translateMatrixAfterRotate(int i, float f, float f2, float f3, int i2, int i3, int i4) {
          float f4 = (float) i3;
          if (f3 < f4) {
              float[] fArr = this.m;
              fArr[i] = (f4 - (((float) i4) * fArr[0])) * 0.5f;
          } else if (f > 0.0f) {
              this.m[i] = -((f3 - f4) * 0.5f);
          } else {
              this.m[i] = -((((Math.abs(f) + (((float) i2) * 0.5f)) / f2) * f3) - (f4 * 0.5f));
          }
      }
  
  
      public void setState(State state2) {
          this.state = state2;
      }
  
      public boolean canScrollHorizontallyFroyo(int i) {
          return canScrollHorizontally(i);
      }
  
      public boolean canScrollHorizontally(int i) {
          this.matrix.getValues(this.m);
          float f = this.m[2];
          if (getImageWidth() < ((float) this.viewWidth)) {
              return false;
          }
          if (f >= -1.0f && i < 0) {
              return false;
          }
          if (Math.abs(f) + ((float) this.viewWidth) + 1.0f < getImageWidth() || i <= 0) {
              return true;
          }
          return false;
      }
  
  
      public void scaleImage(double d, float f, float f2, boolean z) {
          float f3;
          float f4;
          if (z) {
              f3 = this.superMinScale;
              f4 = this.superMaxScale;
          } else {
              f3 = this.minScale;
              f4 = this.maxScale;
          }
          float f5 = this.normalizedScale;
          double d2 = (double) f5;
          Double.isNaN(d2);
          this.normalizedScale = (float) (d2 * d);
          float f6 = this.normalizedScale;
          if (f6 > f4) {
              this.normalizedScale = f4;
              d = (double) (f4 / f5);
          } else if (f6 < f3) {
              this.normalizedScale = f3;
              d = (double) (f3 / f5);
          }
          float f7 = (float) d;
          this.matrix.postScale(f7, f7, f, f2);
          fixScaleTrans();
      }
  
  
      public PointF transformCoordTouchToBitmap(float f, float f2, boolean z) {
          this.matrix.getValues(this.m);
          float intrinsicWidth = (float) getDrawable().getIntrinsicWidth();
          float intrinsicHeight = (float) getDrawable().getIntrinsicHeight();
          float[] fArr = this.m;
          float f3 = fArr[2];
          float imageWidth = ((f - f3) * intrinsicWidth) / getImageWidth();
          float imageHeight = ((f2 - fArr[5]) * intrinsicHeight) / getImageHeight();
          if (z) {
              imageWidth = Math.min(Math.max(imageWidth, 0.0f), intrinsicWidth);
              imageHeight = Math.min(Math.max(imageHeight, 0.0f), intrinsicHeight);
          }
          return new PointF(imageWidth, imageHeight);
      }
  
  
      public PointF transformCoordBitmapToTouch(float f, float f2) {
          this.matrix.getValues(this.m);
          return new PointF(this.m[2] + (getImageWidth() * (f / ((float) getDrawable().getIntrinsicWidth()))), this.m[5] + (getImageHeight() * (f2 / ((float) getDrawable().getIntrinsicHeight()))));
      }
  
  
      @TargetApi(16)
      public void compatPostOnAnimation(Runnable runnable) {
          if (VERSION.SDK_INT >= 16) {
              postOnAnimation(runnable);
          } else {
              postDelayed(runnable, 16);
          }
      }
  
      private void printMatrixInfo() {
          float[] fArr = new float[9];
          this.matrix.getValues(fArr);
          String str = DEBUG;
          StringBuilder sb = new StringBuilder();
          sb.append("Scale: ");
          sb.append(fArr[0]);
          sb.append(" TransX: ");
          sb.append(fArr[2]);
          sb.append(" TransY: ");
          sb.append(fArr[5]);
          Log.d(str, sb.toString());
      }
  }
  