VMOS Pro v2.9.9版本的 MD5 值为:ef77d106fdbb0e499b9232be74ffc054

以下内容为反编译后的 SubsamplingScaleImageView.java 源代码,内容仅作参考


package com.vmos.pro.widget.longimage;

import android.content.Context;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import com.tencent.mars.xlog.Log;
import com.vmos.pro.R;
import com.yalantis.ucrop.view.CropImageView;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
public class SubsamplingScaleImageView extends View {
    public static final String f12390 = "SubsamplingScaleImageView";
    public static final int f12391 = -1;
    public static final int f12392 = 0;
    public static final int f12393 = 90;
    public static final int f12394 = 180;
    public static final int f12395 = 270;
    public static final int f12397 = 1;
    public static final int f12398 = 2;
    public static final int f12399 = 3;
    public static final int f12401 = 1;
    public static final int f12402 = 2;
    public static final int f12404 = 1;
    public static final int f12405 = 2;
    public static final int f12406 = 3;
    public static final int f12408 = 1;
    public static final int f12409 = 2;
    public static final int f12410 = 3;
    public static final int f12412 = 1;
    public static final int f12413 = 2;
    public static final int f12414 = 3;
    public static final int f12415 = 4;
    public static final int f12417 = 1;
    public Bitmap f12418;
    public boolean f12419;
    public boolean f12420;
    public Uri f12421;
    public int f12422;
    public Map<Integer, List<C2143>> f12423;
    public boolean f12424;
    public int f12425;
    public float f12426;
    public float f12427;
    public int f12428;
    public int f12429;
    public int f12430;
    public int f12431;
    public int f12432;
    public boolean f12433;
    public boolean f12434;
    public boolean f12435;
    public boolean f12436;
    public float f12437;
    public int f12438;
    public int f12439;
    public float f12440;
    public float f12441;
    public PointF f12442;
    public PointF f12443;
    public PointF f12444;
    public Float f12445;
    public PointF f12446;
    public PointF f12447;
    public int f12448;
    public int f12449;
    public int f12450;
    public Rect f12451;
    public Rect f12452;
    public boolean f12453;
    public boolean f12454;
    public boolean f12455;
    public int f12456;
    public GestureDetector f12457;
    public x42 f12458;
    public final Object f12459;
    public lc0<? extends f42> f12460;
    public lc0<? extends x42> f12461;
    public PointF f12462;
    public float f12463;
    public final float f12464;
    public float f12465;
    public boolean f12466;
    public PointF f12467;
    public PointF f12468;
    public PointF f12469;
    public C2146 f12470;
    public boolean f12471;
    public boolean f12472;
    public InterfaceC2139 f12473;
    public InterfaceC2140 f12474;
    public View.OnLongClickListener f12475;
    public Handler f12476;
    public Paint f12477;
    public Paint f12478;
    public Paint f12479;
    public C2141 f12480;
    public Matrix f12481;
    public RectF f12482;
    public float[] f12483;
    public float[] f12484;
    public float f12485;
    public static final List<Integer> f12396 = Arrays.asList(0, 90, 180, 270, -1);
    public static final List<Integer> f12400 = Arrays.asList(1, 2, 3);
    public static final List<Integer> f12403 = Arrays.asList(2, 1);
    public static final List<Integer> f12407 = Arrays.asList(1, 2, 3);
    public static final List<Integer> f12411 = Arrays.asList(2, 1, 3);
    public static int f12416 = Integer.MAX_VALUE;

    public final class C2132 {
        public boolean f12486;
        public InterfaceC2138 f12487;
        public final PointF f12489;
        public final PointF f12490;
        public long f12491;
        public int f12492;
        public final float f12493;
        public int f12494;
        public boolean f12495;

        public C2132(SubsamplingScaleImageView subsamplingScaleImageView, float f, PointF pointF, PointF pointF2, C2136 c2136) {
            this(f, pointF, pointF2);
        }

        public final C2132 m15178(int i) {
            this.f12494 = i;
            return this;
        }

        public final C2132 m15179(boolean z) {
            this.f12486 = z;
            return this;
        }

        public void m15180() {
            PointF pointF;
            if (SubsamplingScaleImageView.this.f12470 != null && SubsamplingScaleImageView.this.f12470.f12534 != null) {
                try {
                    SubsamplingScaleImageView.this.f12470.f12534.onInterruptedByNewAnim();
                } catch (Exception e) {
                    Log.w(SubsamplingScaleImageView.f12390, "Error thrown by animation listener", e);
                }
            }
            int paddingLeft = SubsamplingScaleImageView.this.getPaddingLeft() + (((SubsamplingScaleImageView.this.getWidth() - SubsamplingScaleImageView.this.getPaddingRight()) - SubsamplingScaleImageView.this.getPaddingLeft()) / 2);
            int paddingTop = SubsamplingScaleImageView.this.getPaddingTop() + (((SubsamplingScaleImageView.this.getHeight() - SubsamplingScaleImageView.this.getPaddingBottom()) - SubsamplingScaleImageView.this.getPaddingTop()) / 2);
            float m15122 = SubsamplingScaleImageView.this.m15122(this.f12493);
            if (this.f12486) {
                SubsamplingScaleImageView subsamplingScaleImageView = SubsamplingScaleImageView.this;
                PointF pointF2 = this.f12489;
                pointF = subsamplingScaleImageView.m15121(pointF2.x, pointF2.y, m15122, new PointF());
            } else {
                pointF = this.f12489;
            }
            SubsamplingScaleImageView.this.f12470 = new C2146(null);
            SubsamplingScaleImageView.this.f12470.f12535 = SubsamplingScaleImageView.this.f12440;
            SubsamplingScaleImageView.this.f12470.f12528 = m15122;
            SubsamplingScaleImageView.this.f12470.f12531 = System.currentTimeMillis();
            SubsamplingScaleImageView.this.f12470.f12533 = pointF;
            SubsamplingScaleImageView.this.f12470.f12530 = SubsamplingScaleImageView.this.m15101();
            SubsamplingScaleImageView.this.f12470.f12532 = pointF;
            SubsamplingScaleImageView.this.f12470.f12536 = SubsamplingScaleImageView.this.m15149(pointF);
            SubsamplingScaleImageView.this.f12470.f12537 = new PointF(paddingLeft, paddingTop);
            SubsamplingScaleImageView.this.f12470.f12525 = this.f12491;
            SubsamplingScaleImageView.this.f12470.f12526 = this.f12495;
            SubsamplingScaleImageView.this.f12470.f12527 = this.f12492;
            SubsamplingScaleImageView.this.f12470.f12529 = this.f12494;
            SubsamplingScaleImageView.this.f12470.f12531 = System.currentTimeMillis();
            SubsamplingScaleImageView.this.f12470.f12534 = this.f12487;
            PointF pointF3 = this.f12490;
            if (pointF3 != null) {
                float f = pointF3.x - (SubsamplingScaleImageView.this.f12470.f12530.x * m15122);
                float f2 = this.f12490.y - (SubsamplingScaleImageView.this.f12470.f12530.y * m15122);
                C2141 c2141 = new C2141(m15122, new PointF(f, f2), null);
                SubsamplingScaleImageView.this.m15174(true, c2141);
                SubsamplingScaleImageView.this.f12470.f12537 = new PointF(this.f12490.x + (c2141.f12504.x - f), this.f12490.y + (c2141.f12504.y - f2));
            }
            SubsamplingScaleImageView.this.invalidate();
        }

        public C2132 m15181(long j) {
            this.f12491 = j;
            return this;
        }

        public C2132 m15182(int i) {
            if (SubsamplingScaleImageView.f12403.contains(Integer.valueOf(i))) {
                this.f12492 = i;
                return this;
            }
            throw new IllegalArgumentException("Unknown easing type: " + i);
        }

        public C2132 m15183(boolean z) {
            this.f12495 = z;
            return this;
        }

        public C2132 m15184(InterfaceC2138 interfaceC2138) {
            this.f12487 = interfaceC2138;
            return this;
        }

        public C2132(SubsamplingScaleImageView subsamplingScaleImageView, float f, PointF pointF, C2136 c2136) {
            this(f, pointF);
        }

        public C2132(SubsamplingScaleImageView subsamplingScaleImageView, float f, C2136 c2136) {
            this(f);
        }

        public C2132(SubsamplingScaleImageView subsamplingScaleImageView, PointF pointF, C2136 c2136) {
            this(pointF);
        }

        private C2132(PointF pointF) {
            this.f12491 = 500L;
            this.f12492 = 2;
            this.f12494 = 1;
            this.f12495 = true;
            this.f12486 = true;
            this.f12493 = SubsamplingScaleImageView.this.f12440;
            this.f12489 = pointF;
            this.f12490 = null;
        }

        private C2132(float f) {
            this.f12491 = 500L;
            this.f12492 = 2;
            this.f12494 = 1;
            this.f12495 = true;
            this.f12486 = true;
            this.f12493 = f;
            this.f12489 = SubsamplingScaleImageView.this.m15101();
            this.f12490 = null;
        }

        private C2132(float f, PointF pointF) {
            this.f12491 = 500L;
            this.f12492 = 2;
            this.f12494 = 1;
            this.f12495 = true;
            this.f12486 = true;
            this.f12493 = f;
            this.f12489 = pointF;
            this.f12490 = null;
        }

        private C2132(float f, PointF pointF, PointF pointF2) {
            this.f12491 = 500L;
            this.f12492 = 2;
            this.f12494 = 1;
            this.f12495 = true;
            this.f12486 = true;
            this.f12493 = f;
            this.f12489 = pointF;
            this.f12490 = pointF2;
        }
    }

    public static class AsyncTaskC2133 extends AsyncTask<Void, Void, Integer> {
        public final WeakReference<Context> f12496;
        public final WeakReference<lc0<? extends f42>> f12497;
        public final Uri f12498;
        public final boolean f12499;
        public final WeakReference<SubsamplingScaleImageView> f12500;
        public Bitmap f12501;
        public Exception f12502;

        public AsyncTaskC2133(SubsamplingScaleImageView subsamplingScaleImageView, Context context, lc0<? extends f42> lc0Var, Uri uri, boolean z) {
            this.f12500 = new WeakReference<>(subsamplingScaleImageView);
            this.f12496 = new WeakReference<>(context);
            this.f12497 = new WeakReference<>(lc0Var);
            this.f12498 = uri;
            this.f12499 = z;
        }

        @Override
        public void onPostExecute(Integer num) {
            SubsamplingScaleImageView subsamplingScaleImageView = this.f12500.get();
            if (subsamplingScaleImageView != null) {
                Bitmap bitmap = this.f12501;
                if (bitmap != null && num != null) {
                    if (this.f12499) {
                        subsamplingScaleImageView.m15126(bitmap);
                    } else {
                        subsamplingScaleImageView.m15125(bitmap, num.intValue(), false);
                    }
                } else if (this.f12502 == null || subsamplingScaleImageView.f12473 == null) {
                } else {
                    if (this.f12499) {
                        subsamplingScaleImageView.f12473.onPreviewLoadError(this.f12502);
                    } else {
                        subsamplingScaleImageView.f12473.onImageLoadError(this.f12502);
                    }
                }
            }
        }

        @Override
        public Integer doInBackground(Void... voidArr) {
            try {
                String uri = this.f12498.toString();
                Context context = this.f12496.get();
                lc0<? extends f42> lc0Var = this.f12497.get();
                SubsamplingScaleImageView subsamplingScaleImageView = this.f12500.get();
                if (context == null || lc0Var == null || subsamplingScaleImageView == null) {
                    return null;
                }
                subsamplingScaleImageView.m15163("BitmapLoadTask.doInBackground", new Object[0]);
                this.f12501 = lc0Var.make().decode(context, this.f12498);
                return Integer.valueOf(subsamplingScaleImageView.m15102(context, uri));
            } catch (Exception e) {
                Log.e(SubsamplingScaleImageView.f12390, "Failed to load bitmap", e);
                this.f12502 = e;
                return null;
            } catch (OutOfMemoryError e2) {
                Log.e(SubsamplingScaleImageView.f12390, "Failed to load bitmap - OutOfMemoryError", e2);
                this.f12502 = new RuntimeException(e2);
                return null;
            }
        }
    }

    public static class C2134 implements InterfaceC2138 {
        @Override
        public void onComplete() {
        }

        @Override
        public void onInterruptedByNewAnim() {
        }

        @Override
        public void onInterruptedByUser() {
        }
    }

    public static class C2135 implements InterfaceC2139 {
        @Override
        public void onImageLoadError(Exception exc) {
        }

        @Override
        public void onImageLoaded() {
        }

        @Override
        public void onPreviewLoadError(Exception exc) {
        }

        @Override
        public void onPreviewReleased() {
        }

        @Override
        public void onReady() {
        }

        @Override
        public void onTileLoadError(Exception exc) {
        }
    }

    public class C2136 implements Handler.Callback {
        public C2136() {
        }

        @Override
        public boolean handleMessage(Message message) {
            if (message.what == 1 && SubsamplingScaleImageView.this.f12475 != null) {
                SubsamplingScaleImageView.this.f12456 = 0;
                SubsamplingScaleImageView subsamplingScaleImageView = SubsamplingScaleImageView.this;
                SubsamplingScaleImageView.super.setOnLongClickListener(subsamplingScaleImageView.f12475);
                SubsamplingScaleImageView.this.performLongClick();
                SubsamplingScaleImageView.super.setOnLongClickListener(null);
            }
            return true;
        }
    }

    public static class C2137 implements InterfaceC2140 {
        @Override
        public void onCenterChanged(PointF pointF, int i) {
        }

        @Override
        public void onScaleChanged(float f, int i) {
        }
    }

    public interface InterfaceC2138 {
        void onComplete();

        void onInterruptedByNewAnim();

        void onInterruptedByUser();
    }

    public interface InterfaceC2139 {
        void onImageLoadError(Exception exc);

        void onImageLoaded();

        void onPreviewLoadError(Exception exc);

        void onPreviewReleased();

        void onReady();

        void onTileLoadError(Exception exc);
    }

    public interface InterfaceC2140 {
        void onCenterChanged(PointF pointF, int i);

        void onScaleChanged(float f, int i);
    }

    public static class C2141 {
        public PointF f12504;
        public float f12505;

        public C2141(float f, PointF pointF, C2136 c2136) {
            this(f, pointF);
        }

        private C2141(float f, PointF pointF) {
            this.f12505 = f;
            this.f12504 = pointF;
        }
    }

    public class C2142 extends GestureDetector.SimpleOnGestureListener {
        public final Context f12507;

        public C2142(Context context) {
            this.f12507 = context;
        }

        @Override
        public boolean onDoubleTap(MotionEvent motionEvent) {
            if (SubsamplingScaleImageView.this.f12435 && SubsamplingScaleImageView.this.f12471 && SubsamplingScaleImageView.this.f12442 != null) {
                SubsamplingScaleImageView.this.m15145(this.f12507);
                if (SubsamplingScaleImageView.this.f12436) {
                    SubsamplingScaleImageView.this.f12462 = new PointF(motionEvent.getX(), motionEvent.getY());
                    SubsamplingScaleImageView.this.f12443 = new PointF(SubsamplingScaleImageView.this.f12442.x, SubsamplingScaleImageView.this.f12442.y);
                    SubsamplingScaleImageView subsamplingScaleImageView = SubsamplingScaleImageView.this;
                    subsamplingScaleImageView.f12441 = subsamplingScaleImageView.f12440;
                    SubsamplingScaleImageView.this.f12455 = true;
                    SubsamplingScaleImageView.this.f12453 = true;
                    SubsamplingScaleImageView.this.f12465 = -1.0f;
                    SubsamplingScaleImageView subsamplingScaleImageView2 = SubsamplingScaleImageView.this;
                    subsamplingScaleImageView2.f12468 = subsamplingScaleImageView2.m15158(subsamplingScaleImageView2.f12462);
                    SubsamplingScaleImageView.this.f12469 = new PointF(motionEvent.getX(), motionEvent.getY());
                    SubsamplingScaleImageView.this.f12467 = new PointF(SubsamplingScaleImageView.this.f12468.x, SubsamplingScaleImageView.this.f12468.y);
                    SubsamplingScaleImageView.this.f12466 = false;
                    return false;
                }
                SubsamplingScaleImageView subsamplingScaleImageView3 = SubsamplingScaleImageView.this;
                subsamplingScaleImageView3.m15167(subsamplingScaleImageView3.m15158(new PointF(motionEvent.getX(), motionEvent.getY())), new PointF(motionEvent.getX(), motionEvent.getY()));
                return true;
            }
            return super.onDoubleTapEvent(motionEvent);
        }

        @Override
        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
            if (SubsamplingScaleImageView.this.f12434 && SubsamplingScaleImageView.this.f12471 && SubsamplingScaleImageView.this.f12442 != null && motionEvent != null && motionEvent2 != null && ((Math.abs(motionEvent.getX() - motionEvent2.getX()) > 50.0f || Math.abs(motionEvent.getY() - motionEvent2.getY()) > 50.0f) && ((Math.abs(f) > 500.0f || Math.abs(f2) > 500.0f) && !SubsamplingScaleImageView.this.f12453))) {
                PointF pointF = new PointF(SubsamplingScaleImageView.this.f12442.x + (f * 0.25f), SubsamplingScaleImageView.this.f12442.y + (f2 * 0.25f));
                new C2132(SubsamplingScaleImageView.this, new PointF(((SubsamplingScaleImageView.this.getWidth() / 2) - pointF.x) / SubsamplingScaleImageView.this.f12440, ((SubsamplingScaleImageView.this.getHeight() / 2) - pointF.y) / SubsamplingScaleImageView.this.f12440), (C2136) null).m15182(1).m15179(false).m15178(3).m15180();
                return true;
            }
            return super.onFling(motionEvent, motionEvent2, f, f2);
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
            SubsamplingScaleImageView.this.performClick();
            return true;
        }
    }

    public static class C2143 {
        public int f12508;
        public Bitmap f12509;
        public boolean f12510;
        public boolean f12511;
        public Rect f12512;
        public Rect f12513;
        public Rect f12514;

        private C2143() {
        }

        public C2143(C2136 c2136) {
            this();
        }
    }

    public static class AsyncTaskC2144 extends AsyncTask<Void, Void, Bitmap> {
        public final WeakReference<x42> f12515;
        public final WeakReference<C2143> f12516;
        public Exception f12517;
        public final WeakReference<SubsamplingScaleImageView> f12518;

        public AsyncTaskC2144(SubsamplingScaleImageView subsamplingScaleImageView, x42 x42Var, C2143 c2143) {
            this.f12518 = new WeakReference<>(subsamplingScaleImageView);
            this.f12515 = new WeakReference<>(x42Var);
            this.f12516 = new WeakReference<>(c2143);
            c2143.f12510 = true;
        }

        @Override
        public void onPostExecute(Bitmap bitmap) {
            SubsamplingScaleImageView subsamplingScaleImageView = this.f12518.get();
            C2143 c2143 = this.f12516.get();
            if (subsamplingScaleImageView == null || c2143 == null) {
                return;
            }
            if (bitmap != null) {
                c2143.f12509 = bitmap;
                c2143.f12510 = false;
                subsamplingScaleImageView.m15128();
            } else if (this.f12517 == null || subsamplingScaleImageView.f12473 == null) {
            } else {
                subsamplingScaleImageView.f12473.onTileLoadError(this.f12517);
            }
        }

        @Override
        public Bitmap doInBackground(Void... voidArr) {
            Bitmap decodeRegion;
            try {
                SubsamplingScaleImageView subsamplingScaleImageView = this.f12518.get();
                x42 x42Var = this.f12515.get();
                C2143 c2143 = this.f12516.get();
                if (x42Var == null || c2143 == null || subsamplingScaleImageView == null || !x42Var.isReady() || !c2143.f12511) {
                    if (c2143 != null) {
                        c2143.f12510 = false;
                        return null;
                    }
                    return null;
                }
                subsamplingScaleImageView.m15163("TileLoadTask.doInBackground, tile.sRect=%s, tile.sampleSize=%d", c2143.f12512, Integer.valueOf(c2143.f12508));
                synchronized (subsamplingScaleImageView.f12459) {
                    subsamplingScaleImageView.m15172(c2143.f12512, c2143.f12514);
                    if (subsamplingScaleImageView.f12451 != null) {
                        c2143.f12514.offset(subsamplingScaleImageView.f12451.left, subsamplingScaleImageView.f12451.top);
                    }
                    decodeRegion = x42Var.decodeRegion(c2143.f12514, c2143.f12508);
                }
                return decodeRegion;
            } catch (Exception e) {
                Log.e(SubsamplingScaleImageView.f12390, "Failed to decode tile", e);
                this.f12517 = e;
                return null;
            } catch (OutOfMemoryError e2) {
                Log.e(SubsamplingScaleImageView.f12390, "Failed to decode tile - OutOfMemoryError", e2);
                this.f12517 = new RuntimeException(e2);
                return null;
            }
        }
    }

    public static class AsyncTaskC2145 extends AsyncTask<Void, Void, int[]> {
        public final WeakReference<Context> f12519;
        public final WeakReference<lc0<? extends x42>> f12520;
        public final Uri f12521;
        public x42 f12522;
        public final WeakReference<SubsamplingScaleImageView> f12523;
        public Exception f12524;

        public AsyncTaskC2145(SubsamplingScaleImageView subsamplingScaleImageView, Context context, lc0<? extends x42> lc0Var, Uri uri) {
            this.f12523 = new WeakReference<>(subsamplingScaleImageView);
            this.f12519 = new WeakReference<>(context);
            this.f12520 = new WeakReference<>(lc0Var);
            this.f12521 = uri;
        }

        @Override
        public void onPostExecute(int[] iArr) {
            SubsamplingScaleImageView subsamplingScaleImageView = this.f12523.get();
            if (subsamplingScaleImageView != null) {
                x42 x42Var = this.f12522;
                if (x42Var != null && iArr != null && iArr.length == 3) {
                    subsamplingScaleImageView.m15129(x42Var, iArr[0], iArr[1], iArr[2]);
                } else if (this.f12524 == null || subsamplingScaleImageView.f12473 == null) {
                } else {
                    subsamplingScaleImageView.f12473.onImageLoadError(this.f12524);
                }
            }
        }

        @Override
        public int[] doInBackground(Void... voidArr) {
            try {
                String uri = this.f12521.toString();
                Context context = this.f12519.get();
                lc0<? extends x42> lc0Var = this.f12520.get();
                SubsamplingScaleImageView subsamplingScaleImageView = this.f12523.get();
                if (context == null || lc0Var == null || subsamplingScaleImageView == null) {
                    return null;
                }
                subsamplingScaleImageView.m15163("TilesInitTask.doInBackground", new Object[0]);
                x42 make = lc0Var.make();
                this.f12522 = make;
                Point init = make.init(context, this.f12521);
                int i = init.x;
                int i2 = init.y;
                int m15102 = subsamplingScaleImageView.m15102(context, uri);
                if (subsamplingScaleImageView.f12451 != null) {
                    i = subsamplingScaleImageView.f12451.width();
                    i2 = subsamplingScaleImageView.f12451.height();
                }
                return new int[]{i, i2, m15102};
            } catch (Exception e) {
                Log.e(SubsamplingScaleImageView.f12390, "Failed to initialise bitmap decoder", e);
                this.f12524 = e;
                return null;
            }
        }
    }

    public SubsamplingScaleImageView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        int resourceId;
        String string;
        this.f12425 = 0;
        this.f12426 = 2.0f;
        this.f12427 = m15123();
        this.f12428 = -1;
        this.f12429 = 1;
        this.f12430 = 1;
        int i = f12416;
        this.f12431 = i;
        this.f12432 = i;
        this.f12434 = true;
        this.f12435 = true;
        this.f12436 = true;
        this.f12437 = 1.0f;
        this.f12438 = 1;
        this.f12439 = CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION;
        this.f12459 = new Object();
        this.f12460 = new xv(ye5.class);
        this.f12461 = new xv(ze5.class);
        this.f12483 = new float[8];
        this.f12484 = new float[8];
        this.f12485 = getResources().getDisplayMetrics().density;
        setMinimumDpi(160);
        setDoubleTapZoomDpi(160);
        m15145(context);
        this.f12476 = new Handler(new C2136());
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.styleable.SubsamplingScaleImageView);
            if (obtainStyledAttributes.hasValue(0) && (string = obtainStyledAttributes.getString(0)) != null && string.length() > 0) {
                setImage(a52.m314(string).m328());
            }
            if (obtainStyledAttributes.hasValue(4) && (resourceId = obtainStyledAttributes.getResourceId(4, 0)) > 0) {
                setImage(a52.m313(resourceId).m328());
            }
            if (obtainStyledAttributes.hasValue(1)) {
                setPanEnabled(obtainStyledAttributes.getBoolean(1, true));
            }
            if (obtainStyledAttributes.hasValue(6)) {
                setZoomEnabled(obtainStyledAttributes.getBoolean(6, true));
            }
            if (obtainStyledAttributes.hasValue(2)) {
                setQuickScaleEnabled(obtainStyledAttributes.getBoolean(2, true));
            }
            if (obtainStyledAttributes.hasValue(5)) {
                setTileBackgroundColor(obtainStyledAttributes.getColor(5, Color.argb(0, 0, 0, 0)));
            }
            obtainStyledAttributes.recycle();
        }
        this.f12464 = TypedValue.applyDimension(1, 20.0f, context.getResources().getDisplayMetrics());
    }

    @Override
    public void onDraw(Canvas canvas) {
        Bitmap bitmap;
        float f;
        Locale locale;
        super.onDraw(canvas);
        m15162();
        if (this.f12448 == 0 || this.f12449 == 0 || getWidth() == 0 || getHeight() == 0) {
            return;
        }
        if (this.f12423 == null && this.f12458 != null) {
            m15113(m15103(canvas));
        }
        if (m15161()) {
            m15131();
            if (this.f12470 != null) {
                float f2 = this.f12440;
                if (this.f12444 == null) {
                    this.f12444 = new PointF(0.0f, 0.0f);
                }
                this.f12444.set(this.f12442);
                long currentTimeMillis = System.currentTimeMillis() - this.f12470.f12531;
                boolean z = currentTimeMillis > this.f12470.f12525;
                long min = Math.min(currentTimeMillis, this.f12470.f12525);
                this.f12440 = m15168(this.f12470.f12527, min, this.f12470.f12535, this.f12470.f12528 - this.f12470.f12535, this.f12470.f12525);
                float m15168 = m15168(this.f12470.f12527, min, this.f12470.f12536.x, this.f12470.f12537.x - this.f12470.f12536.x, this.f12470.f12525);
                float m151682 = m15168(this.f12470.f12527, min, this.f12470.f12536.y, this.f12470.f12537.y - this.f12470.f12536.y, this.f12470.f12525);
                this.f12442.x -= m15152(this.f12470.f12532.x) - m15168;
                this.f12442.y -= m15153(this.f12470.f12532.y) - m151682;
                m15173(z || this.f12470.f12535 == this.f12470.f12528);
                m15143(f2, this.f12444, this.f12470.f12529);
                m15133(z);
                if (z) {
                    if (this.f12470.f12534 != null) {
                        try {
                            this.f12470.f12534.onComplete();
                        } catch (Exception e) {
                            Log.w(f12390, "Error thrown by animation listener", e);
                        }
                    }
                    this.f12470 = null;
                }
                invalidate();
            }
            if (this.f12423 != null && m15115()) {
                int min2 = Math.min(this.f12422, m15144(this.f12440));
                boolean z2 = false;
                for (Map.Entry<Integer, List<C2143>> entry : this.f12423.entrySet()) {
                    if (entry.getKey().intValue() == min2) {
                        for (C2143 c2143 : entry.getValue()) {
                            if (c2143.f12511 && (c2143.f12510 || c2143.f12509 == null)) {
                                z2 = true;
                            }
                        }
                    }
                }
                for (Map.Entry<Integer, List<C2143>> entry2 : this.f12423.entrySet()) {
                    if (entry2.getKey().intValue() == min2 || z2) {
                        for (C2143 c21432 : entry2.getValue()) {
                            m15151(c21432.f12512, c21432.f12513);
                            if (c21432.f12510 || c21432.f12509 == null) {
                                if (c21432.f12510 && this.f12424) {
                                    canvas.drawText("LOADING", c21432.f12513.left + 5, c21432.f12513.top + 35, this.f12478);
                                }
                            } else {
                                if (this.f12479 != null) {
                                    canvas.drawRect(c21432.f12513, this.f12479);
                                }
                                if (this.f12481 == null) {
                                    this.f12481 = new Matrix();
                                }
                                this.f12481.reset();
                                m15146(this.f12483, 0.0f, 0.0f, c21432.f12509.getWidth(), 0.0f, c21432.f12509.getWidth(), c21432.f12509.getHeight(), 0.0f, c21432.f12509.getHeight());
                                if (m15107() == 0) {
                                    m15146(this.f12484, c21432.f12513.left, c21432.f12513.top, c21432.f12513.right, c21432.f12513.top, c21432.f12513.right, c21432.f12513.bottom, c21432.f12513.left, c21432.f12513.bottom);
                                } else if (m15107() == 90) {
                                    m15146(this.f12484, c21432.f12513.right, c21432.f12513.top, c21432.f12513.right, c21432.f12513.bottom, c21432.f12513.left, c21432.f12513.bottom, c21432.f12513.left, c21432.f12513.top);
                                } else if (m15107() == 180) {
                                    m15146(this.f12484, c21432.f12513.right, c21432.f12513.bottom, c21432.f12513.left, c21432.f12513.bottom, c21432.f12513.left, c21432.f12513.top, c21432.f12513.right, c21432.f12513.top);
                                } else if (m15107() == 270) {
                                    m15146(this.f12484, c21432.f12513.left, c21432.f12513.bottom, c21432.f12513.left, c21432.f12513.top, c21432.f12513.right, c21432.f12513.top, c21432.f12513.right, c21432.f12513.bottom);
                                }
                                this.f12481.setPolyToPoly(this.f12483, 0, this.f12484, 0, 4);
                                canvas.drawBitmap(c21432.f12509, this.f12481, this.f12477);
                                if (this.f12424) {
                                    canvas.drawRect(c21432.f12513, this.f12478);
                                }
                            }
                            if (c21432.f12511 && this.f12424) {
                                canvas.drawText("ISS " + c21432.f12508 + " RECT " + c21432.f12512.top + jo6.f22033 + c21432.f12512.left + jo6.f22033 + c21432.f12512.bottom + jo6.f22033 + c21432.f12512.right, c21432.f12513.left + 5, c21432.f12513.top + 15, this.f12478);
                            }
                        }
                    }
                }
            } else {
                if (this.f12418 != null) {
                    float f3 = this.f12440;
                    if (this.f12419) {
                        f3 *= this.f12448 / bitmap.getWidth();
                        f = this.f12440 * (this.f12449 / this.f12418.getHeight());
                    } else {
                        f = f3;
                    }
                    if (this.f12481 == null) {
                        this.f12481 = new Matrix();
                    }
                    this.f12481.reset();
                    this.f12481.postScale(f3, f);
                    this.f12481.postRotate(m15107());
                    Matrix matrix = this.f12481;
                    PointF pointF = this.f12442;
                    matrix.postTranslate(pointF.x, pointF.y);
                    if (m15107() == 180) {
                        Matrix matrix2 = this.f12481;
                        float f4 = this.f12440;
                        matrix2.postTranslate(this.f12448 * f4, f4 * this.f12449);
                    } else if (m15107() == 90) {
                        this.f12481.postTranslate(this.f12440 * this.f12449, 0.0f);
                    } else if (m15107() == 270) {
                        this.f12481.postTranslate(0.0f, this.f12440 * this.f12448);
                    }
                    if (this.f12479 != null) {
                        if (this.f12482 == null) {
                            this.f12482 = new RectF();
                        }
                        this.f12482.set(0.0f, 0.0f, this.f12419 ? this.f12418.getWidth() : this.f12448, this.f12419 ? this.f12418.getHeight() : this.f12449);
                        this.f12481.mapRect(this.f12482);
                        canvas.drawRect(this.f12482, this.f12479);
                    }
                    canvas.drawBitmap(this.f12418, this.f12481, this.f12477);
                }
            }
            if (this.f12424) {
                StringBuilder sb = new StringBuilder();
                sb.append("Scale: ");
                sb.append(String.format(Locale.ENGLISH, "%.2f", Float.valueOf(this.f12440)));
                canvas.drawText(sb.toString(), 5.0f, 15.0f, this.f12478);
                canvas.drawText("Translate: " + String.format(locale, "%.2f", Float.valueOf(this.f12442.x)) + ":" + String.format(locale, "%.2f", Float.valueOf(this.f12442.y)), 5.0f, 35.0f, this.f12478);
                PointF m15101 = m15101();
                canvas.drawText("Source center: " + String.format(locale, "%.2f", Float.valueOf(m15101.x)) + ":" + String.format(locale, "%.2f", Float.valueOf(m15101.y)), 5.0f, 55.0f, this.f12478);
                this.f12478.setStrokeWidth(2.0f);
                C2146 c2146 = this.f12470;
                if (c2146 != null) {
                    PointF m15149 = m15149(c2146.f12530);
                    PointF m151492 = m15149(this.f12470.f12533);
                    PointF m151493 = m15149(this.f12470.f12532);
                    canvas.drawCircle(m15149.x, m15149.y, 10.0f, this.f12478);
                    this.f12478.setColor(-65536);
                    canvas.drawCircle(m151492.x, m151492.y, 20.0f, this.f12478);
                    this.f12478.setColor(-16776961);
                    canvas.drawCircle(m151493.x, m151493.y, 25.0f, this.f12478);
                    this.f12478.setColor(-16711681);
                    canvas.drawCircle(getWidth() / 2, getHeight() / 2, 30.0f, this.f12478);
                }
                if (this.f12462 != null) {
                    this.f12478.setColor(-65536);
                    PointF pointF2 = this.f12462;
                    canvas.drawCircle(pointF2.x, pointF2.y, 20.0f, this.f12478);
                }
                if (this.f12468 != null) {
                    this.f12478.setColor(-16776961);
                    canvas.drawCircle(m15152(this.f12468.x), m15153(this.f12468.y), 35.0f, this.f12478);
                }
                if (this.f12469 != null) {
                    this.f12478.setColor(-16711681);
                    PointF pointF3 = this.f12469;
                    canvas.drawCircle(pointF3.x, pointF3.y, 30.0f, this.f12478);
                }
                this.f12478.setColor(-65281);
                this.f12478.setStrokeWidth(1.0f);
            }
        }
    }

    @Override
    public void onMeasure(int i, int i2) {
        int mode = View.MeasureSpec.getMode(i);
        int mode2 = View.MeasureSpec.getMode(i2);
        int size = View.MeasureSpec.getSize(i);
        int size2 = View.MeasureSpec.getSize(i2);
        boolean z = mode != 1073741824;
        boolean z2 = mode2 != 1073741824;
        if (this.f12448 > 0 && this.f12449 > 0) {
            if (z && z2) {
                size = m15142();
                size2 = m15141();
            } else if (z2) {
                size2 = (int) ((m15141() / m15142()) * size);
            } else if (z) {
                size = (int) ((m15142() / m15141()) * size2);
            }
        }
        setMeasuredDimension(Math.max(size, getSuggestedMinimumWidth()), Math.max(size2, getSuggestedMinimumHeight()));
    }

    @Override
    public void onSizeChanged(int i, int i2, int i3, int i4) {
        m15163("onSizeChanged %dx%d -> %dx%d", Integer.valueOf(i3), Integer.valueOf(i4), Integer.valueOf(i), Integer.valueOf(i2));
        PointF m15101 = m15101();
        if (!this.f12471 || m15101 == null) {
            return;
        }
        this.f12470 = null;
        this.f12445 = Float.valueOf(this.f12440);
        this.f12446 = m15101;
    }

    @Override
    public boolean onTouchEvent(@NonNull MotionEvent motionEvent) {
        GestureDetector gestureDetector;
        C2146 c2146 = this.f12470;
        if (c2146 != null && !c2146.f12526) {
            m15137(true);
            return true;
        }
        C2146 c21462 = this.f12470;
        if (c21462 != null && c21462.f12534 != null) {
            try {
                this.f12470.f12534.onInterruptedByUser();
            } catch (Exception e) {
                Log.w(f12390, "Error thrown by animation listener", e);
            }
        }
        this.f12470 = null;
        if (this.f12442 == null) {
            return true;
        }
        if (!this.f12455 && ((gestureDetector = this.f12457) == null || gestureDetector.onTouchEvent(motionEvent))) {
            this.f12453 = false;
            this.f12454 = false;
            this.f12456 = 0;
            return true;
        }
        if (this.f12443 == null) {
            this.f12443 = new PointF(0.0f, 0.0f);
        }
        if (this.f12444 == null) {
            this.f12444 = new PointF(0.0f, 0.0f);
        }
        if (this.f12462 == null) {
            this.f12462 = new PointF(0.0f, 0.0f);
        }
        float f = this.f12440;
        this.f12444.set(this.f12442);
        boolean m15130 = m15130(motionEvent);
        m15143(f, this.f12444, 2);
        return m15130 || super.onTouchEvent(motionEvent);
    }

    public final void setBitmapDecoderClass(Class<? extends f42> cls) {
        if (cls != null) {
            this.f12460 = new xv(cls);
            return;
        }
        throw new IllegalArgumentException("Decoder class cannot be set to null");
    }

    public final void setBitmapDecoderFactory(lc0<? extends f42> lc0Var) {
        if (lc0Var != null) {
            this.f12460 = lc0Var;
            return;
        }
        throw new IllegalArgumentException("Decoder factory cannot be set to null");
    }

    public final void setDebug(boolean z) {
        this.f12424 = z;
    }

    public final void setDoubleTapZoomDpi(int i) {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        setDoubleTapZoomScale(((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f) / i);
    }

    public final void setDoubleTapZoomDuration(int i) {
        this.f12439 = Math.max(0, i);
    }

    public final void setDoubleTapZoomScale(float f) {
        this.f12437 = f;
    }

    public final void setDoubleTapZoomStyle(int i) {
        if (f12400.contains(Integer.valueOf(i))) {
            this.f12438 = i;
            return;
        }
        throw new IllegalArgumentException("Invalid zoom style: " + i);
    }

    public final void setImage(a52 a52Var) {
        setImage(a52Var, null, null);
    }

    public final void setMaxScale(float f) {
        this.f12426 = f;
    }

    public void setMaxTileSize(int i) {
        this.f12431 = i;
        this.f12432 = i;
    }

    public final void setMaximumDpi(int i) {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        setMinScale(((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f) / i);
    }

    public final void setMinScale(float f) {
        this.f12427 = f;
    }

    public final void setMinimumDpi(int i) {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        setMaxScale(((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f) / i);
    }

    public final void setMinimumScaleType(int i) {
        if (f12411.contains(Integer.valueOf(i))) {
            this.f12430 = i;
            if (m15119()) {
                m15173(true);
                invalidate();
                return;
            }
            return;
        }
        throw new IllegalArgumentException("Invalid scale type: " + i);
    }

    public void setMinimumTileDpi(int i) {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        this.f12428 = (int) Math.min((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f, i);
        if (m15119()) {
            m15138(false);
            invalidate();
        }
    }

    public void setOnImageEventListener(InterfaceC2139 interfaceC2139) {
        this.f12473 = interfaceC2139;
    }

    @Override
    public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
        this.f12475 = onLongClickListener;
    }

    public void setOnStateChangedListener(InterfaceC2140 interfaceC2140) {
        this.f12474 = interfaceC2140;
    }

    public final void setOrientation(int i) {
        if (f12396.contains(Integer.valueOf(i))) {
            this.f12425 = i;
            m15138(false);
            invalidate();
            requestLayout();
            return;
        }
        throw new IllegalArgumentException("Invalid orientation: " + i);
    }

    public final void setPanEnabled(boolean z) {
        PointF pointF;
        this.f12434 = z;
        if (z || (pointF = this.f12442) == null) {
            return;
        }
        pointF.x = (getWidth() / 2) - (this.f12440 * (m15142() / 2));
        this.f12442.y = (getHeight() / 2) - (this.f12440 * (m15141() / 2));
        if (m15119()) {
            m15133(true);
            invalidate();
        }
    }

    public final void setPanLimit(int i) {
        if (f12407.contains(Integer.valueOf(i))) {
            this.f12429 = i;
            if (m15119()) {
                m15173(true);
                invalidate();
                return;
            }
            return;
        }
        throw new IllegalArgumentException("Invalid pan limit: " + i);
    }

    public void setParallelLoadingEnabled(boolean z) {
        this.f12433 = z;
    }

    public final void setQuickScaleEnabled(boolean z) {
        this.f12436 = z;
    }

    public final void setRegionDecoderClass(Class<? extends x42> cls) {
        if (cls != null) {
            this.f12461 = new xv(cls);
            return;
        }
        throw new IllegalArgumentException("Decoder class cannot be set to null");
    }

    public final void setRegionDecoderFactory(lc0<? extends x42> lc0Var) {
        if (lc0Var != null) {
            this.f12461 = lc0Var;
            return;
        }
        throw new IllegalArgumentException("Decoder factory cannot be set to null");
    }

    public final void setScaleAndCenter(float f, PointF pointF) {
        this.f12470 = null;
        this.f12445 = Float.valueOf(f);
        this.f12446 = pointF;
        this.f12447 = pointF;
        invalidate();
    }

    public final void setTileBackgroundColor(int i) {
        if (Color.alpha(i) == 0) {
            this.f12479 = null;
        } else {
            Paint paint = new Paint();
            this.f12479 = paint;
            paint.setStyle(Paint.Style.FILL);
            this.f12479.setColor(i);
        }
        invalidate();
    }

    public final void setZoomEnabled(boolean z) {
        this.f12435 = z;
    }

    public final PointF m15101() {
        return m15156(getWidth() / 2, getHeight() / 2);
    }

    @AnyThread
    public final int m15102(Context context, String str) {
        int i = 0;
        if (str.startsWith("content")) {
            Cursor cursor = null;
            try {
                try {
                    cursor = context.getContentResolver().query(Uri.parse(str), new String[]{"orientation"}, null, null, null);
                    if (cursor != null && cursor.moveToFirst()) {
                        int i2 = cursor.getInt(0);
                        if (!f12396.contains(Integer.valueOf(i2)) || i2 == -1) {
                            Log.w(f12390, "Unsupported orientation: " + i2);
                        } else {
                            i = i2;
                        }
                    }
                    if (cursor == null) {
                        return i;
                    }
                } catch (Exception unused) {
                    Log.w(f12390, "Could not get orientation of image from media store");
                    if (cursor == null) {
                        return 0;
                    }
                }
                cursor.close();
                return i;
            } catch (Throwable th) {
                if (cursor != null) {
                    cursor.close();
                }
                throw th;
            }
        } else if (!str.startsWith("file:///") || str.startsWith("file:///android_asset/")) {
            return 0;
        } else {
            try {
                int attributeInt = new ExifInterface(str.substring(7)).getAttributeInt(androidx.exifinterface.media.ExifInterface.TAG_ORIENTATION, 1);
                if (attributeInt != 1 && attributeInt != 0) {
                    if (attributeInt == 6) {
                        return 90;
                    }
                    if (attributeInt == 3) {
                        return 180;
                    }
                    if (attributeInt == 8) {
                        return 270;
                    }
                    Log.w(f12390, "Unsupported EXIF orientation: " + attributeInt);
                    return 0;
                }
                return 0;
            } catch (Exception unused2) {
                Log.w(f12390, "Could not get EXIF orientation of image");
                return 0;
            }
        }
    }

    public final Point m15103(Canvas canvas) {
        int i;
        int intValue;
        int i2 = 2048;
        if (Build.VERSION.SDK_INT >= 14) {
            try {
                i = ((Integer) Canvas.class.getMethod("getMaximumBitmapWidth", new Class[0]).invoke(canvas, new Object[0])).intValue();
                try {
                    intValue = ((Integer) Canvas.class.getMethod("getMaximumBitmapHeight", new Class[0]).invoke(canvas, new Object[0])).intValue();
                    i2 = i;
                } catch (Exception unused) {
                    i2 = i;
                    intValue = 2048;
                    return new Point(Math.min(i2, this.f12431), Math.min(intValue, this.f12432));
                }
            } catch (Exception unused2) {
                i = 2048;
            }
            return new Point(Math.min(i2, this.f12431), Math.min(intValue, this.f12432));
        }
        intValue = 2048;
        return new Point(Math.min(i2, this.f12431), Math.min(intValue, this.f12432));
    }

    public float m15104() {
        return this.f12426;
    }

    public final float m15105() {
        return m15123();
    }

    public final int m15106() {
        return this.f12425;
    }

    @AnyThread
    public final int m15107() {
        int i = this.f12425;
        return i == -1 ? this.f12450 : i;
    }

    public final int m15108() {
        return this.f12449;
    }

    public final int m15109() {
        return this.f12448;
    }

    public final float m15110() {
        return this.f12440;
    }

    public final d52 m15111() {
        if (this.f12442 == null || this.f12448 <= 0 || this.f12449 <= 0) {
            return null;
        }
        return new d52(m15110(), m15101(), m15106());
    }

    public boolean m15112() {
        return (this.f12421 == null && this.f12418 == null) ? false : true;
    }

    public final synchronized void m15113(Point point) {
        m15163("initialiseBaseLayer maxTileDimensions=%dx%d", Integer.valueOf(point.x), Integer.valueOf(point.y));
        C2141 c2141 = new C2141(0.0f, new PointF(0.0f, 0.0f), null);
        this.f12480 = c2141;
        m15174(true, c2141);
        int m15144 = m15144(this.f12480.f12505);
        this.f12422 = m15144;
        if (m15144 > 1) {
            this.f12422 = m15144 / 2;
        }
        if (this.f12422 == 1 && this.f12451 == null && m15142() < point.x && m15141() < point.y) {
            this.f12458.recycle();
            this.f12458 = null;
            m15171(new AsyncTaskC2133(this, getContext(), this.f12460, this.f12421, false));
        } else {
            m15114(point);
            for (C2143 c2143 : this.f12423.get(Integer.valueOf(this.f12422))) {
                m15171(new AsyncTaskC2144(this, this.f12458, c2143));
            }
            m15133(true);
        }
    }

    public final void m15114(Point point) {
        int i = 1;
        m15163("initialiseTileMap maxTileDimensions=%dx%d", Integer.valueOf(point.x), Integer.valueOf(point.y));
        this.f12423 = new LinkedHashMap();
        int i2 = this.f12422;
        int i3 = 1;
        int i4 = 1;
        while (true) {
            int m15142 = m15142() / i3;
            int m15141 = m15141() / i4;
            int i5 = m15142 / i2;
            int i6 = m15141 / i2;
            while (true) {
                if (i5 + i3 + i > point.x || (i5 > getWidth() * 1.25d && i2 < this.f12422)) {
                    i3++;
                    m15142 = m15142() / i3;
                    i5 = m15142 / i2;
                    i = 1;
                }
            }
            while (true) {
                if (i6 + i4 + i > point.y || (i6 > getHeight() * 1.25d && i2 < this.f12422)) {
                    i4++;
                    m15141 = m15141() / i4;
                    i6 = m15141 / i2;
                    i = 1;
                }
            }
            ArrayList arrayList = new ArrayList(i3 * i4);
            int i7 = 0;
            while (i7 < i3) {
                int i8 = 0;
                while (i8 < i4) {
                    C2143 c2143 = new C2143(null);
                    c2143.f12508 = i2;
                    c2143.f12511 = i2 == this.f12422;
                    c2143.f12512 = new Rect(i7 * m15142, i8 * m15141, i7 == i3 + (-1) ? m15142() : (i7 + 1) * m15142, i8 == i4 + (-1) ? m15141() : (i8 + 1) * m15141);
                    c2143.f12513 = new Rect(0, 0, 0, 0);
                    c2143.f12514 = new Rect(c2143.f12512);
                    arrayList.add(c2143);
                    i8++;
                }
                i7++;
            }
            this.f12423.put(Integer.valueOf(i2), arrayList);
            if (i2 == 1) {
                return;
            }
            i2 /= 2;
            i = 1;
        }
    }

    public final boolean m15115() {
        boolean z = true;
        if (this.f12418 == null || this.f12419) {
            Map<Integer, List<C2143>> map = this.f12423;
            if (map != null) {
                for (Map.Entry<Integer, List<C2143>> entry : map.entrySet()) {
                    if (entry.getKey().intValue() == this.f12422) {
                        for (C2143 c2143 : entry.getValue()) {
                            if (c2143.f12510 || c2143.f12509 == null) {
                                z = false;
                            }
                        }
                    }
                }
                return z;
            }
            return false;
        }
        return true;
    }

    public final boolean m15116() {
        return this.f12472;
    }

    public final boolean m15117() {
        return this.f12434;
    }

    public final boolean m15118() {
        return this.f12436;
    }

    public final boolean m15119() {
        return this.f12471;
    }

    public final boolean m15120() {
        return this.f12435;
    }

    public final PointF m15121(float f, float f2, float f3, PointF pointF) {
        PointF m15155 = m15155(f, f2, f3);
        pointF.set(((getPaddingLeft() + (((getWidth() - getPaddingRight()) - getPaddingLeft()) / 2)) - m15155.x) / f3, ((getPaddingTop() + (((getHeight() - getPaddingBottom()) - getPaddingTop()) / 2)) - m15155.y) / f3);
        return pointF;
    }

    public final float m15122(float f) {
        return Math.min(this.f12426, Math.max(m15123(), f));
    }

    public final float m15123() {
        int paddingBottom = getPaddingBottom() + getPaddingTop();
        int paddingLeft = getPaddingLeft() + getPaddingRight();
        int i = this.f12430;
        if (i == 2) {
            return Math.max((getWidth() - paddingLeft) / m15142(), (getHeight() - paddingBottom) / m15141());
        }
        if (i == 3) {
            float f = this.f12427;
            if (f > 0.0f) {
                return f;
            }
        }
        return Math.min((getWidth() - paddingLeft) / m15142(), (getHeight() - paddingBottom) / m15141());
    }

    public void m15124() {
    }

    public final synchronized void m15125(Bitmap bitmap, int i, boolean z) {
        InterfaceC2139 interfaceC2139;
        m15163("onImageLoaded", new Object[0]);
        int i2 = this.f12448;
        if (i2 > 0 && this.f12449 > 0 && (i2 != bitmap.getWidth() || this.f12449 != bitmap.getHeight())) {
            m15138(false);
        }
        Bitmap bitmap2 = this.f12418;
        if (bitmap2 != null && !this.f12420) {
            bitmap2.recycle();
        }
        if (this.f12418 != null && this.f12420 && (interfaceC2139 = this.f12473) != null) {
            interfaceC2139.onPreviewReleased();
        }
        this.f12419 = false;
        this.f12420 = z;
        this.f12418 = bitmap;
        this.f12448 = bitmap.getWidth();
        this.f12449 = bitmap.getHeight();
        this.f12450 = i;
        boolean m15161 = m15161();
        boolean m15160 = m15160();
        if (m15161 || m15160) {
            invalidate();
            requestLayout();
        }
    }

    public final synchronized void m15126(Bitmap bitmap) {
        m15163("onPreviewLoaded", new Object[0]);
        if (this.f12418 == null && !this.f12472) {
            Rect rect = this.f12452;
            if (rect != null) {
                this.f12418 = Bitmap.createBitmap(bitmap, rect.left, rect.top, rect.width(), this.f12452.height());
            } else {
                this.f12418 = bitmap;
            }
            this.f12419 = true;
            if (m15161()) {
                invalidate();
                requestLayout();
            }
            return;
        }
        bitmap.recycle();
    }

    public void m15127() {
    }

    public final synchronized void m15128() {
        Bitmap bitmap;
        m15163("onTileLoaded", new Object[0]);
        m15161();
        m15160();
        if (m15115() && (bitmap = this.f12418) != null) {
            if (!this.f12420) {
                bitmap.recycle();
            }
            this.f12418 = null;
            InterfaceC2139 interfaceC2139 = this.f12473;
            if (interfaceC2139 != null && this.f12420) {
                interfaceC2139.onPreviewReleased();
            }
            this.f12419 = false;
            this.f12420 = false;
        }
        invalidate();
    }

    public final synchronized void m15129(x42 x42Var, int i, int i2, int i3) {
        int i4;
        int i5;
        int i6;
        int i7;
        m15163("onTilesInited sWidth=%d, sHeight=%d, sOrientation=%d", Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(this.f12425));
        int i8 = this.f12448;
        if (i8 > 0 && (i7 = this.f12449) > 0 && (i8 != i || i7 != i2)) {
            m15138(false);
            Bitmap bitmap = this.f12418;
            if (bitmap != null) {
                if (!this.f12420) {
                    bitmap.recycle();
                }
                this.f12418 = null;
                InterfaceC2139 interfaceC2139 = this.f12473;
                if (interfaceC2139 != null && this.f12420) {
                    interfaceC2139.onPreviewReleased();
                }
                this.f12419 = false;
                this.f12420 = false;
            }
        }
        this.f12458 = x42Var;
        this.f12448 = i;
        this.f12449 = i2;
        this.f12450 = i3;
        m15161();
        if (!m15160() && (i4 = this.f12431) > 0 && i4 != (i5 = f12416) && (i6 = this.f12432) > 0 && i6 != i5 && getWidth() > 0 && getHeight() > 0) {
            m15113(new Point(this.f12431, this.f12432));
        }
        invalidate();
        requestLayout();
    }

    public final boolean m15130(@NonNull MotionEvent motionEvent) {
        boolean z;
        boolean z2;
        int pointerCount = motionEvent.getPointerCount();
        int action = motionEvent.getAction();
        if (action != 0) {
            if (action != 1) {
                if (action == 2) {
                    if (this.f12456 > 0) {
                        if (pointerCount >= 2) {
                            float m15165 = m15165(motionEvent.getX(0), motionEvent.getX(1), motionEvent.getY(0), motionEvent.getY(1));
                            float x = (motionEvent.getX(0) + motionEvent.getX(1)) / 2.0f;
                            float y = (motionEvent.getY(0) + motionEvent.getY(1)) / 2.0f;
                            if (this.f12435) {
                                PointF pointF = this.f12462;
                                if (m15165(pointF.x, x, pointF.y, y) > 5.0f || Math.abs(m15165 - this.f12463) > 5.0f || this.f12454) {
                                    this.f12453 = true;
                                    this.f12454 = true;
                                    double d = this.f12440;
                                    float min = Math.min(this.f12426, (m15165 / this.f12463) * this.f12441);
                                    this.f12440 = min;
                                    if (min <= m15123()) {
                                        this.f12463 = m15165;
                                        this.f12441 = m15123();
                                        this.f12462.set(x, y);
                                        this.f12443.set(this.f12442);
                                    } else if (this.f12434) {
                                        PointF pointF2 = this.f12462;
                                        float f = pointF2.x;
                                        PointF pointF3 = this.f12443;
                                        float f2 = f - pointF3.x;
                                        float f3 = pointF2.y - pointF3.y;
                                        float f4 = this.f12440;
                                        float f5 = this.f12441;
                                        float f6 = f3 * (f4 / f5);
                                        PointF pointF4 = this.f12442;
                                        pointF4.x = x - (f2 * (f4 / f5));
                                        pointF4.y = y - f6;
                                        if ((m15141() * d < getHeight() && this.f12440 * m15141() >= getHeight()) || (d * m15142() < getWidth() && this.f12440 * m15142() >= getWidth())) {
                                            m15173(true);
                                            this.f12462.set(x, y);
                                            this.f12443.set(this.f12442);
                                            this.f12441 = this.f12440;
                                            this.f12463 = m15165;
                                        }
                                    } else if (this.f12447 != null) {
                                        this.f12442.x = (getWidth() / 2) - (this.f12440 * this.f12447.x);
                                        this.f12442.y = (getHeight() / 2) - (this.f12440 * this.f12447.y);
                                    } else {
                                        this.f12442.x = (getWidth() / 2) - (this.f12440 * (m15142() / 2));
                                        this.f12442.y = (getHeight() / 2) - (this.f12440 * (m15141() / 2));
                                    }
                                    m15173(true);
                                    m15133(false);
                                    z2 = true;
                                }
                            }
                        } else {
                            if (this.f12455) {
                                float abs = (Math.abs(this.f12469.y - motionEvent.getY()) * 2.0f) + this.f12464;
                                if (this.f12465 == -1.0f) {
                                    this.f12465 = abs;
                                }
                                float y2 = motionEvent.getY();
                                PointF pointF5 = this.f12467;
                                boolean z3 = y2 > pointF5.y;
                                pointF5.set(0.0f, motionEvent.getY());
                                float abs2 = Math.abs(1.0f - (abs / this.f12465)) * 0.5f;
                                if (abs2 > 0.03f || this.f12466) {
                                    this.f12466 = true;
                                    float f7 = this.f12465 > 0.0f ? z3 ? abs2 + 1.0f : 1.0f - abs2 : 1.0f;
                                    double d2 = this.f12440;
                                    float max = Math.max(m15123(), Math.min(this.f12426, this.f12440 * f7));
                                    this.f12440 = max;
                                    if (this.f12434) {
                                        PointF pointF6 = this.f12462;
                                        float f8 = pointF6.x;
                                        PointF pointF7 = this.f12443;
                                        float f9 = pointF6.y;
                                        float f10 = this.f12441;
                                        float f11 = (f9 - pointF7.y) * (max / f10);
                                        PointF pointF8 = this.f12442;
                                        pointF8.x = f8 - ((f8 - pointF7.x) * (max / f10));
                                        pointF8.y = f9 - f11;
                                        if ((m15141() * d2 < getHeight() && this.f12440 * m15141() >= getHeight()) || (d2 * m15142() < getWidth() && this.f12440 * m15142() >= getWidth())) {
                                            m15173(true);
                                            this.f12462.set(m15149(this.f12468));
                                            this.f12443.set(this.f12442);
                                            this.f12441 = this.f12440;
                                            abs = 0.0f;
                                        }
                                    } else if (this.f12447 != null) {
                                        this.f12442.x = (getWidth() / 2) - (this.f12440 * this.f12447.x);
                                        this.f12442.y = (getHeight() / 2) - (this.f12440 * this.f12447.y);
                                    } else {
                                        this.f12442.x = (getWidth() / 2) - (this.f12440 * (m15142() / 2));
                                        this.f12442.y = (getHeight() / 2) - (this.f12440 * (m15141() / 2));
                                    }
                                }
                                this.f12465 = abs;
                                m15173(true);
                                m15133(false);
                            } else if (!this.f12453) {
                                float abs3 = Math.abs(motionEvent.getX() - this.f12462.x);
                                float abs4 = Math.abs(motionEvent.getY() - this.f12462.y);
                                float f12 = this.f12485 * 5.0f;
                                int i = (abs3 > f12 ? 1 : (abs3 == f12 ? 0 : -1));
                                if (i > 0 || abs4 > f12 || this.f12454) {
                                    this.f12442.x = this.f12443.x + (motionEvent.getX() - this.f12462.x);
                                    this.f12442.y = this.f12443.y + (motionEvent.getY() - this.f12462.y);
                                    PointF pointF9 = this.f12442;
                                    float f13 = pointF9.x;
                                    float f14 = pointF9.y;
                                    m15173(true);
                                    PointF pointF10 = this.f12442;
                                    boolean z4 = f13 != pointF10.x;
                                    float f15 = pointF10.y;
                                    boolean z5 = f14 != f15;
                                    boolean z6 = z4 && abs3 > abs4 && !this.f12454;
                                    boolean z7 = z5 && abs4 > abs3 && !this.f12454;
                                    boolean z8 = f14 == f15 && abs4 > 3.0f * f12;
                                    if (!z6 && !z7 && (!z4 || !z5 || z8 || this.f12454)) {
                                        this.f12454 = true;
                                    } else if (i > 0 || abs4 > f12) {
                                        this.f12456 = 0;
                                        this.f12476.removeMessages(1);
                                        m15137(false);
                                    }
                                    if (!this.f12434) {
                                        PointF pointF11 = this.f12442;
                                        PointF pointF12 = this.f12443;
                                        pointF11.x = pointF12.x;
                                        pointF11.y = pointF12.y;
                                        m15137(false);
                                    }
                                    m15133(false);
                                }
                            }
                            z2 = true;
                        }
                        if (z2) {
                            this.f12476.removeMessages(1);
                            invalidate();
                            return true;
                        }
                    }
                    z2 = false;
                    if (z2) {
                    }
                } else if (action != 5) {
                    if (action != 6) {
                        if (action != 261) {
                        }
                    }
                }
                return false;
            }
            this.f12476.removeMessages(1);
            if (this.f12455) {
                this.f12455 = false;
                if (!this.f12466) {
                    m15167(this.f12468, this.f12462);
                }
            }
            if (this.f12456 <= 0 || !((z = this.f12453) || this.f12454)) {
                if (pointerCount == 1) {
                    this.f12453 = false;
                    this.f12454 = false;
                    this.f12456 = 0;
                }
                return true;
            }
            if (z && pointerCount == 2) {
                this.f12454 = true;
                PointF pointF13 = this.f12443;
                PointF pointF14 = this.f12442;
                pointF13.set(pointF14.x, pointF14.y);
                if (motionEvent.getActionIndex() == 1) {
                    this.f12462.set(motionEvent.getX(0), motionEvent.getY(0));
                } else {
                    this.f12462.set(motionEvent.getX(1), motionEvent.getY(1));
                }
            }
            if (pointerCount < 3) {
                this.f12453 = false;
            }
            if (pointerCount < 2) {
                this.f12454 = false;
                this.f12456 = 0;
            }
            m15133(true);
            return true;
        }
        this.f12470 = null;
        m15137(true);
        this.f12456 = Math.max(this.f12456, pointerCount);
        if (pointerCount >= 2) {
            if (this.f12435) {
                float m151652 = m15165(motionEvent.getX(0), motionEvent.getX(1), motionEvent.getY(0), motionEvent.getY(1));
                this.f12441 = this.f12440;
                this.f12463 = m151652;
                PointF pointF15 = this.f12443;
                PointF pointF16 = this.f12442;
                pointF15.set(pointF16.x, pointF16.y);
                this.f12462.set((motionEvent.getX(0) + motionEvent.getX(1)) / 2.0f, (motionEvent.getY(0) + motionEvent.getY(1)) / 2.0f);
            } else {
                this.f12456 = 0;
            }
            this.f12476.removeMessages(1);
        } else if (!this.f12455) {
            PointF pointF17 = this.f12443;
            PointF pointF18 = this.f12442;
            pointF17.set(pointF18.x, pointF18.y);
            this.f12462.set(motionEvent.getX(), motionEvent.getY());
            this.f12476.sendEmptyMessageDelayed(1, 600L);
        }
        return true;
    }

    public final void m15131() {
        Float f;
        if (getWidth() == 0 || getHeight() == 0 || this.f12448 <= 0 || this.f12449 <= 0) {
            return;
        }
        if (this.f12446 != null && (f = this.f12445) != null) {
            this.f12440 = f.floatValue();
            if (this.f12442 == null) {
                this.f12442 = new PointF();
            }
            this.f12442.x = (getWidth() / 2) - (this.f12440 * this.f12446.x);
            this.f12442.y = (getHeight() / 2) - (this.f12440 * this.f12446.y);
            this.f12446 = null;
            this.f12445 = null;
            m15173(true);
            m15133(true);
        }
        m15173(false);
    }

    public void m15132() {
        m15138(true);
        this.f12477 = null;
        this.f12478 = null;
        this.f12479 = null;
    }

    public final void m15133(boolean z) {
        if (this.f12458 == null || this.f12423 == null) {
            return;
        }
        int min = Math.min(this.f12422, m15144(this.f12440));
        for (Map.Entry<Integer, List<C2143>> entry : this.f12423.entrySet()) {
            for (C2143 c2143 : entry.getValue()) {
                if (c2143.f12508 < min || (c2143.f12508 > min && c2143.f12508 != this.f12422)) {
                    c2143.f12511 = false;
                    if (c2143.f12509 != null) {
                        c2143.f12509.recycle();
                        c2143.f12509 = null;
                    }
                }
                if (c2143.f12508 != min) {
                    if (c2143.f12508 == this.f12422) {
                        c2143.f12511 = true;
                    }
                } else if (m15154(c2143)) {
                    c2143.f12511 = true;
                    if (!c2143.f12510 && c2143.f12509 == null && z) {
                        m15171(new AsyncTaskC2144(this, this.f12458, c2143));
                    }
                } else if (c2143.f12508 != this.f12422) {
                    c2143.f12511 = false;
                    if (c2143.f12509 != null) {
                        c2143.f12509.recycle();
                        c2143.f12509 = null;
                    }
                }
            }
        }
    }

    public C2132 m15134(PointF pointF) {
        if (m15119()) {
            return new C2132(this, pointF, (C2136) null);
        }
        return null;
    }

    public C2132 m15135(float f) {
        if (m15119()) {
            return new C2132(this, f, (C2136) null);
        }
        return null;
    }

    public C2132 m15136(float f, PointF pointF) {
        if (m15119()) {
            return new C2132(this, f, pointF, (C2136) null);
        }
        return null;
    }

    public final void m15137(boolean z) {
        ViewParent parent = getParent();
        if (parent != null) {
            parent.requestDisallowInterceptTouchEvent(z);
        }
    }

    public final void m15138(boolean z) {
        InterfaceC2139 interfaceC2139;
        m15163("reset newImage=" + z, new Object[0]);
        this.f12440 = 0.0f;
        this.f12441 = 0.0f;
        this.f12442 = null;
        this.f12443 = null;
        this.f12444 = null;
        this.f12445 = Float.valueOf(0.0f);
        this.f12446 = null;
        this.f12447 = null;
        this.f12453 = false;
        this.f12454 = false;
        this.f12455 = false;
        this.f12456 = 0;
        this.f12422 = 0;
        this.f12462 = null;
        this.f12463 = 0.0f;
        this.f12465 = 0.0f;
        this.f12466 = false;
        this.f12468 = null;
        this.f12467 = null;
        this.f12469 = null;
        this.f12470 = null;
        this.f12480 = null;
        this.f12481 = null;
        this.f12482 = null;
        if (z) {
            this.f12421 = null;
            if (this.f12458 != null) {
                synchronized (this.f12459) {
                    this.f12458.recycle();
                    this.f12458 = null;
                }
            }
            Bitmap bitmap = this.f12418;
            if (bitmap != null && !this.f12420) {
                bitmap.recycle();
            }
            if (this.f12418 != null && this.f12420 && (interfaceC2139 = this.f12473) != null) {
                interfaceC2139.onPreviewReleased();
            }
            this.f12448 = 0;
            this.f12449 = 0;
            this.f12450 = 0;
            this.f12451 = null;
            this.f12452 = null;
            this.f12471 = false;
            this.f12472 = false;
            this.f12418 = null;
            this.f12419 = false;
            this.f12420 = false;
        }
        Map<Integer, List<C2143>> map = this.f12423;
        if (map != null) {
            for (Map.Entry<Integer, List<C2143>> entry : map.entrySet()) {
                for (C2143 c2143 : entry.getValue()) {
                    c2143.f12511 = false;
                    if (c2143.f12509 != null) {
                        c2143.f12509.recycle();
                        c2143.f12509 = null;
                    }
                }
            }
            this.f12423 = null;
        }
        m15145(getContext());
    }

    public final void m15139() {
        this.f12470 = null;
        this.f12445 = Float.valueOf(m15122(0.0f));
        if (m15119()) {
            this.f12446 = new PointF(m15142() / 2, m15141() / 2);
        } else {
            this.f12446 = new PointF(0.0f, 0.0f);
        }
        invalidate();
    }

    public final void m15140(d52 d52Var) {
        if (d52Var == null || d52Var.m16672() == null || !f12396.contains(Integer.valueOf(d52Var.m16670()))) {
            return;
        }
        this.f12425 = d52Var.m16670();
        this.f12445 = Float.valueOf(d52Var.m16671());
        this.f12446 = d52Var.m16672();
        invalidate();
    }

    public final int m15141() {
        int m15107 = m15107();
        if (m15107 != 90 && m15107 != 270) {
            return this.f12449;
        }
        return this.f12448;
    }

    public final int m15142() {
        int m15107 = m15107();
        if (m15107 != 90 && m15107 != 270) {
            return this.f12448;
        }
        return this.f12449;
    }

    public final void m15143(float f, PointF pointF, int i) {
        InterfaceC2140 interfaceC2140 = this.f12474;
        if (interfaceC2140 != null) {
            float f2 = this.f12440;
            if (f2 != f) {
                interfaceC2140.onScaleChanged(f2, i);
            }
            if (this.f12442.equals(pointF)) {
                return;
            }
            this.f12474.onCenterChanged(m15101(), i);
        }
    }

    public final int m15144(float f) {
        int round;
        if (this.f12428 > 0) {
            DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
            f *= this.f12428 / ((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f);
        }
        int m15142 = (int) (m15142() * f);
        int m15141 = (int) (m15141() * f);
        if (m15142 == 0 || m15141 == 0) {
            return 32;
        }
        int i = 1;
        if (m15141() > m15141 || m15142() > m15142) {
            round = Math.round(m15141() / m15141);
            int round2 = Math.round(m15142() / m15142);
            if (round >= round2) {
                round = round2;
            }
        } else {
            round = 1;
        }
        while (true) {
            int i2 = i * 2;
            if (i2 >= round) {
                return i;
            }
            i = i2;
        }
    }

    public final void m15145(Context context) {
        this.f12457 = new GestureDetector(context, new C2142(context));
    }

    public final void m15146(float[] fArr, float f, float f2, float f3, float f4, float f5, float f6, float f7, float f8) {
        fArr[0] = f;
        fArr[1] = f2;
        fArr[2] = f3;
        fArr[3] = f4;
        fArr[4] = f5;
        fArr[5] = f6;
        fArr[6] = f7;
        fArr[7] = f8;
    }

    public final PointF m15147(float f, float f2) {
        return m15148(f, f2, new PointF());
    }

    public final PointF m15148(float f, float f2, PointF pointF) {
        if (this.f12442 == null) {
            return null;
        }
        pointF.set(m15152(f), m15153(f2));
        return pointF;
    }

    public final PointF m15149(PointF pointF) {
        return m15148(pointF.x, pointF.y, new PointF());
    }

    public final PointF m15150(PointF pointF, PointF pointF2) {
        return m15148(pointF.x, pointF.y, pointF2);
    }

    public final Rect m15151(Rect rect, Rect rect2) {
        rect2.set((int) m15152(rect.left), (int) m15153(rect.top), (int) m15152(rect.right), (int) m15153(rect.bottom));
        return rect2;
    }

    public final float m15152(float f) {
        PointF pointF = this.f12442;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f * this.f12440) + pointF.x;
    }

    public final float m15153(float f) {
        PointF pointF = this.f12442;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f * this.f12440) + pointF.y;
    }

    public final boolean m15154(C2143 c2143) {
        return m15164(0.0f) <= ((float) c2143.f12512.right) && ((float) c2143.f12512.left) <= m15164((float) getWidth()) && m15166(0.0f) <= ((float) c2143.f12512.bottom) && ((float) c2143.f12512.top) <= m15166((float) getHeight());
    }

    public final PointF m15155(float f, float f2, float f3) {
        int paddingLeft = getPaddingLeft() + (((getWidth() - getPaddingRight()) - getPaddingLeft()) / 2);
        int paddingTop = getPaddingTop() + (((getHeight() - getPaddingBottom()) - getPaddingTop()) / 2);
        if (this.f12480 == null) {
            this.f12480 = new C2141(0.0f, new PointF(0.0f, 0.0f), null);
        }
        this.f12480.f12505 = f3;
        this.f12480.f12504.set(paddingLeft - (f * f3), paddingTop - (f2 * f3));
        m15174(true, this.f12480);
        return this.f12480.f12504;
    }

    public final PointF m15156(float f, float f2) {
        return m15157(f, f2, new PointF());
    }

    public final PointF m15157(float f, float f2, PointF pointF) {
        if (this.f12442 == null) {
            return null;
        }
        pointF.set(m15164(f), m15166(f2));
        return pointF;
    }

    public final PointF m15158(PointF pointF) {
        return m15157(pointF.x, pointF.y, new PointF());
    }

    public final PointF m15159(PointF pointF, PointF pointF2) {
        return m15157(pointF.x, pointF.y, pointF2);
    }

    public final boolean m15160() {
        boolean m15115 = m15115();
        if (!this.f12472 && m15115) {
            m15131();
            this.f12472 = true;
            m15124();
            InterfaceC2139 interfaceC2139 = this.f12473;
            if (interfaceC2139 != null) {
                interfaceC2139.onImageLoaded();
            }
        }
        return m15115;
    }

    public final boolean m15161() {
        boolean z = getWidth() > 0 && getHeight() > 0 && this.f12448 > 0 && this.f12449 > 0 && (this.f12418 != null || m15115());
        if (!this.f12471 && z) {
            m15131();
            this.f12471 = true;
            m15127();
            InterfaceC2139 interfaceC2139 = this.f12473;
            if (interfaceC2139 != null) {
                interfaceC2139.onReady();
            }
        }
        return z;
    }

    public final void m15162() {
        if (this.f12477 == null) {
            Paint paint = new Paint();
            this.f12477 = paint;
            paint.setAntiAlias(true);
            this.f12477.setFilterBitmap(true);
            this.f12477.setDither(true);
        }
        if (this.f12478 == null && this.f12424) {
            Paint paint2 = new Paint();
            this.f12478 = paint2;
            paint2.setTextSize(18.0f);
            this.f12478.setColor(-65281);
            this.f12478.setStyle(Paint.Style.STROKE);
        }
    }

    @AnyThread
    public final void m15163(String str, Object... objArr) {
        if (this.f12424) {
            Log.d(f12390, String.format(str, objArr));
        }
    }

    public final float m15164(float f) {
        PointF pointF = this.f12442;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f - pointF.x) / this.f12440;
    }

    public final float m15165(float f, float f2, float f3, float f4) {
        float f5 = f - f2;
        float f6 = f3 - f4;
        return (float) Math.sqrt((f5 * f5) + (f6 * f6));
    }

    public final float m15166(float f) {
        PointF pointF = this.f12442;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f - pointF.y) / this.f12440;
    }

    public final void m15167(PointF pointF, PointF pointF2) {
        if (!this.f12434) {
            PointF pointF3 = this.f12447;
            if (pointF3 != null) {
                pointF.x = pointF3.x;
                pointF.y = pointF3.y;
            } else {
                pointF.x = m15142() / 2;
                pointF.y = m15141() / 2;
            }
        }
        float min = Math.min(this.f12426, this.f12437);
        boolean z = ((double) this.f12440) <= ((double) min) * 0.9d;
        if (!z) {
            min = m15123();
        }
        float f = min;
        int i = this.f12438;
        if (i == 3) {
            setScaleAndCenter(f, pointF);
        } else if (i == 2 || !z || !this.f12434) {
            new C2132(this, f, pointF, (C2136) null).m15183(false).m15181(this.f12439).m15178(4).m15180();
        } else if (i == 1) {
            new C2132(this, f, pointF, pointF2, null).m15183(false).m15181(this.f12439).m15178(4).m15180();
        }
        invalidate();
    }

    public final float m15168(int i, long j, float f, float f2, long j2) {
        if (i != 1) {
            if (i == 2) {
                return m15169(j, f, f2, j2);
            }
            throw new IllegalStateException("Unexpected easing type: " + i);
        }
        return m15170(j, f, f2, j2);
    }

    public final float m15169(long j, float f, float f2, long j2) {
        float f3;
        float f4 = ((float) j) / (((float) j2) / 2.0f);
        if (f4 < 1.0f) {
            f3 = (f2 / 2.0f) * f4;
        } else {
            float f5 = f4 - 1.0f;
            f3 = (-f2) / 2.0f;
            f4 = (f5 * (f5 - 2.0f)) - 1.0f;
        }
        return (f3 * f4) + f;
    }

    public final float m15170(long j, float f, float f2, long j2) {
        float f3 = ((float) j) / ((float) j2);
        return ((-f2) * f3 * (f3 - 2.0f)) + f;
    }

    public final void m15171(AsyncTask<Void, Void, ?> asyncTask) {
        if (this.f12433 && Build.VERSION.SDK_INT >= 11) {
            try {
                AsyncTask.class.getMethod("executeOnExecutor", Executor.class, Object[].class).invoke(asyncTask, (Executor) AsyncTask.class.getField("THREAD_POOL_EXECUTOR").get(null), null);
                return;
            } catch (Exception e) {
                Log.i(f12390, "Failed to execute AsyncTask on thread pool executor, falling back to single threaded executor", e);
            }
        }
        asyncTask.execute(new Void[0]);
    }

    @AnyThread
    public final void m15172(Rect rect, Rect rect2) {
        if (m15107() == 0) {
            rect2.set(rect);
        } else if (m15107() == 90) {
            int i = rect.top;
            int i2 = this.f12449;
            rect2.set(i, i2 - rect.right, rect.bottom, i2 - rect.left);
        } else if (m15107() == 180) {
            int i3 = this.f12448;
            int i4 = this.f12449;
            rect2.set(i3 - rect.right, i4 - rect.bottom, i3 - rect.left, i4 - rect.top);
        } else {
            int i5 = this.f12448;
            rect2.set(i5 - rect.bottom, rect.left, i5 - rect.top, rect.right);
        }
    }

    public final void m15173(boolean z) {
        boolean z2;
        if (this.f12442 == null) {
            z2 = true;
            this.f12442 = new PointF(0.0f, 0.0f);
        } else {
            z2 = false;
        }
        if (this.f12480 == null) {
            this.f12480 = new C2141(0.0f, new PointF(0.0f, 0.0f), null);
        }
        this.f12480.f12505 = this.f12440;
        this.f12480.f12504.set(this.f12442);
        m15174(z, this.f12480);
        this.f12440 = this.f12480.f12505;
        this.f12442.set(this.f12480.f12504);
        if (z2) {
            this.f12442.set(m15155(m15142() / 2, m15141() / 2, this.f12440));
        }
    }

    public final void m15174(boolean z, C2141 c2141) {
        float max;
        int max2;
        float max3;
        if (this.f12429 == 2 && m15119()) {
            z = false;
        }
        PointF pointF = c2141.f12504;
        float m15122 = m15122(c2141.f12505);
        float m15142 = m15142() * m15122;
        float m15141 = m15141() * m15122;
        if (this.f12429 == 3 && m15119()) {
            pointF.x = Math.max(pointF.x, (getWidth() / 2) - m15142);
            pointF.y = Math.max(pointF.y, (getHeight() / 2) - m15141);
        } else if (z) {
            pointF.x = Math.max(pointF.x, getWidth() - m15142);
            pointF.y = Math.max(pointF.y, getHeight() - m15141);
        } else {
            pointF.x = Math.max(pointF.x, -m15142);
            pointF.y = Math.max(pointF.y, -m15141);
        }
        float f = 0.5f;
        float paddingLeft = (getPaddingLeft() > 0 || getPaddingRight() > 0) ? getPaddingLeft() / (getPaddingLeft() + getPaddingRight()) : 0.5f;
        if (getPaddingTop() > 0 || getPaddingBottom() > 0) {
            f = getPaddingTop() / (getPaddingTop() + getPaddingBottom());
        }
        if (this.f12429 == 3 && m15119()) {
            max = Math.max(0, getWidth() / 2);
            max2 = Math.max(0, getHeight() / 2);
        } else if (z) {
            max = Math.max(0.0f, (getWidth() - m15142) * paddingLeft);
            max3 = Math.max(0.0f, (getHeight() - m15141) * f);
            pointF.x = Math.min(pointF.x, max);
            pointF.y = Math.min(pointF.y, max3);
            c2141.f12505 = m15122;
        } else {
            max = Math.max(0, getWidth());
            max2 = Math.max(0, getHeight());
        }
        max3 = max2;
        pointF.x = Math.min(pointF.x, max);
        pointF.y = Math.min(pointF.y, max3);
        c2141.f12505 = m15122;
    }

    public final int m15175() {
        return m15107();
    }

    public final void setImage(a52 a52Var, d52 d52Var) {
        setImage(a52Var, null, d52Var);
    }

    public final void setImage(a52 a52Var, a52 a52Var2) {
        setImage(a52Var, a52Var2, null);
    }

    public void setMaxTileSize(int i, int i2) {
        this.f12431 = i;
        this.f12432 = i2;
    }

    public final void setImage(a52 a52Var, a52 a52Var2, d52 d52Var) {
        Objects.requireNonNull(a52Var, "imageSource must not be null");
        m15138(true);
        if (d52Var != null) {
            m15140(d52Var);
        }
        if (a52Var2 != null) {
            if (a52Var.m322() == null) {
                if (a52Var.m317() > 0 && a52Var.m329() > 0) {
                    this.f12448 = a52Var.m317();
                    this.f12449 = a52Var.m329();
                    this.f12452 = a52Var2.m316();
                    if (a52Var2.m322() != null) {
                        this.f12420 = a52Var2.m320();
                        m15126(a52Var2.m322());
                    } else {
                        Uri m319 = a52Var2.m319();
                        if (m319 == null && a52Var2.m327() != null) {
                            m319 = Uri.parse("android.resource://" + getContext().getPackageName() + "/" + a52Var2.m327());
                        }
                        m15171(new AsyncTaskC2133(this, getContext(), this.f12460, m319, true));
                    }
                } else {
                    throw new IllegalArgumentException("Preview image cannot be used unless dimensions are provided for the main image");
                }
            } else {
                throw new IllegalArgumentException("Preview image cannot be used when a bitmap is provided for the main image");
            }
        }
        if (a52Var.m322() != null && a52Var.m316() != null) {
            m15125(Bitmap.createBitmap(a52Var.m322(), a52Var.m316().left, a52Var.m316().top, a52Var.m316().width(), a52Var.m316().height()), 0, false);
        } else if (a52Var.m322() != null) {
            m15125(a52Var.m322(), 0, a52Var.m320());
        } else {
            this.f12451 = a52Var.m316();
            Uri m3192 = a52Var.m319();
            this.f12421 = m3192;
            if (m3192 == null && a52Var.m327() != null) {
                this.f12421 = Uri.parse("android.resource://" + getContext().getPackageName() + "/" + a52Var.m327());
            }
            if (!a52Var.m318() && this.f12451 == null) {
                m15171(new AsyncTaskC2133(this, getContext(), this.f12460, this.f12421, false));
            } else {
                m15171(new AsyncTaskC2145(this, getContext(), this.f12461, this.f12421));
            }
        }
    }

    public static class C2146 {
        public long f12525;
        public boolean f12526;
        public int f12527;
        public float f12528;
        public int f12529;
        public PointF f12530;
        public long f12531;
        public PointF f12532;
        public PointF f12533;
        public InterfaceC2138 f12534;
        public float f12535;
        public PointF f12536;
        public PointF f12537;

        private C2146() {
            this.f12525 = 500L;
            this.f12526 = true;
            this.f12527 = 2;
            this.f12529 = 1;
            this.f12531 = System.currentTimeMillis();
        }

        public C2146(C2136 c2136) {
            this();
        }
    }

    public SubsamplingScaleImageView(Context context) {
        this(context, null);
    }
}