导航菜单

页面标题

页面副标题

万能钥匙 v1.1.23 - c.java 源代码

正在查看: 万能钥匙 v1.1.23 应用的 c.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.finogeeks.lib.applet.externallib.subscaleview;

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.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.finogeeks.lib.applet.R;
import com.finogeeks.lib.applet.externallib.subscaleview.decoder.SkiaImageDecoder;
import com.finogeeks.lib.applet.externallib.subscaleview.decoder.SkiaImageRegionDecoder;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class c extends View {
    private static Bitmap.Config B0;
    private PointF A;
    private PointF B;
    private Float C;
    private PointF D;
    private PointF E;
    private int F;
    private int G;
    private int H;
    private Rect I;
    private Rect J;
    private boolean K;
    private boolean L;
    private boolean M;
    private int N;
    private GestureDetector O;
    private GestureDetector P;
    private com.finogeeks.lib.applet.externallib.subscaleview.decoder.d Q;
    private final ReadWriteLock R;
    private com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.c> S;
    private com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.d> T;
    private PointF U;
    private float V;
    private final float W;
    private Bitmap a;
    private float a0;
    private boolean b;
    private boolean b0;
    private boolean c;
    private PointF c0;
    private Uri d;
    private PointF d0;
    private int e;
    private PointF e0;
    private Map<Integer, List<k>> f;
    private d f0;
    private boolean g;
    private boolean g0;
    private int h;
    private boolean h0;
    private float i;
    private h i0;
    private float j;
    private i j0;
    private int k;
    private View.OnLongClickListener k0;
    private int l;
    private final Handler l0;
    private int m;
    private Paint m0;
    private int n;
    private Paint n0;
    private int o;
    private Paint o0;
    private Executor p;
    private Paint p0;
    private boolean q;
    private j q0;
    private boolean r;
    private Matrix r0;
    private boolean s;
    private RectF s0;
    private boolean t;
    private final float[] t0;
    private float u;
    private final float[] u0;
    private int v;
    private final float v0;
    private int w;
    private float x;

    private float f83y;

    private PointF f84z;
    private static final List<Integer> w0 = Arrays.asList(0, 90, 180, 270, -1);
    private static final List<Integer> x0 = Arrays.asList(1, 2, 3);

    private static final List<Integer> f81y0 = Arrays.asList(2, 1);

    private static final List<Integer> f82z0 = Arrays.asList(1, 2, 3);
    private static final List<Integer> A0 = Arrays.asList(2, 1, 3, 4);

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

        @Override
        public boolean handleMessage(Message message) {
            if (message.what == 1 && c.this.k0 != null) {
                c.this.N = 0;
                c cVar = c.this;
                c.super.setOnLongClickListener(cVar.k0);
                c.this.performLongClick();
                c.super.setOnLongClickListener(null);
            }
            return true;
        }
    }

    public class b extends GestureDetector.SimpleOnGestureListener {
        final Context a;

        public b(Context context) {
            this.a = context;
        }

        @Override
        public boolean onDoubleTap(MotionEvent motionEvent) {
            if (!c.this.s || !c.this.g0 || c.this.f84z == null) {
                return super.onDoubleTapEvent(motionEvent);
            }
            c.this.setGestureDetector(this.a);
            if (!c.this.t) {
                c cVar = c.this;
                cVar.a(cVar.b(new PointF(motionEvent.getX(), motionEvent.getY())), new PointF(motionEvent.getX(), motionEvent.getY()));
                return true;
            }
            c.this.U = new PointF(motionEvent.getX(), motionEvent.getY());
            c cVar2 = c.this;
            cVar2.A = new PointF(cVar2.f84z.x, c.this.f84z.y);
            c cVar3 = c.this;
            cVar3.f83y = cVar3.x;
            c.this.M = true;
            c.this.K = true;
            c.this.a0 = -1.0f;
            c cVar4 = c.this;
            cVar4.d0 = cVar4.b(cVar4.U);
            c.this.e0 = new PointF(motionEvent.getX(), motionEvent.getY());
            c cVar5 = c.this;
            cVar5.c0 = new PointF(cVar5.d0.x, c.this.d0.y);
            c.this.b0 = false;
            return false;
        }

        @Override
        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
            if (!c.this.r || !c.this.g0 || c.this.f84z == 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) || c.this.K))) {
                return super.onFling(motionEvent, motionEvent2, f, f2);
            }
            PointF pointF = new PointF(c.this.f84z.x + (f * 0.25f), c.this.f84z.y + (f2 * 0.25f));
            new e(c.this, new PointF(((c.this.getWidth() / 2) - pointF.x) / c.this.x, ((c.this.getHeight() / 2) - pointF.y) / c.this.x), (a) null).a(1).b(false).b(3).a();
            return true;
        }

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

    public class C0101c extends GestureDetector.SimpleOnGestureListener {
        public C0101c() {
        }

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

    public static class d {
        private float a;
        private float b;
        private PointF c;
        private PointF d;
        private PointF e;
        private PointF f;
        private PointF g;
        private long h;
        private boolean i;
        private int j;
        private int k;
        private long l;
        private g m;

        private d() {
            this.h = 500L;
            this.i = true;
            this.j = 2;
            this.k = 1;
            this.l = System.currentTimeMillis();
        }

        public d(a aVar) {
            this();
        }
    }

    public final class e {
        private final float a;
        private final PointF b;
        private final PointF c;
        private long d;
        private int e;
        private int f;
        private boolean g;
        private boolean h;
        private g i;

        private e(float f, PointF pointF) {
            this.d = 500L;
            this.e = 2;
            this.f = 1;
            this.g = true;
            this.h = true;
            this.a = f;
            this.b = pointF;
            this.c = null;
        }

        private e(float f, PointF pointF, PointF pointF2) {
            this.d = 500L;
            this.e = 2;
            this.f = 1;
            this.g = true;
            this.h = true;
            this.a = f;
            this.b = pointF;
            this.c = pointF2;
        }

        public e(c cVar, float f, PointF pointF, PointF pointF2, a aVar) {
            this(f, pointF, pointF2);
        }

        public e(c cVar, float f, PointF pointF, a aVar) {
            this(f, pointF);
        }

        private e(PointF pointF) {
            this.d = 500L;
            this.e = 2;
            this.f = 1;
            this.g = true;
            this.h = true;
            this.a = c.this.x;
            this.b = pointF;
            this.c = null;
        }

        public e(c cVar, PointF pointF, a aVar) {
            this(pointF);
        }

        @NonNull
        public e b(int i) {
            this.f = i;
            return this;
        }

        @NonNull
        public e b(boolean z10) {
            this.h = z10;
            return this;
        }

        @NonNull
        public e a(int i) {
            if (c.f81y0.contains(Integer.valueOf(i))) {
                this.e = i;
                return this;
            }
            throw new IllegalArgumentException("Unknown easing type: " + i);
        }

        @NonNull
        public e a(long j) {
            this.d = j;
            return this;
        }

        @NonNull
        public e a(boolean z10) {
            this.g = z10;
            return this;
        }

        public void a() {
            PointF pointF;
            if (c.this.f0 != null && c.this.f0.m != null) {
                try {
                    c.this.f0.m.c();
                } catch (Exception e) {
                    Log.w("SubsamplingScaleIV", "Error thrown by animation listener", e);
                }
            }
            int paddingLeft = c.this.getPaddingLeft() + (((c.this.getWidth() - c.this.getPaddingRight()) - c.this.getPaddingLeft()) / 2);
            int paddingTop = c.this.getPaddingTop() + (((c.this.getHeight() - c.this.getPaddingBottom()) - c.this.getPaddingTop()) / 2);
            float b = c.this.b(this.a);
            if (this.h) {
                c cVar = c.this;
                PointF pointF2 = this.b;
                pointF = cVar.a(pointF2.x, pointF2.y, b, new PointF());
            } else {
                pointF = this.b;
            }
            a aVar = null;
            c.this.f0 = new d(aVar);
            c.this.f0.a = c.this.x;
            c.this.f0.b = b;
            c.this.f0.l = System.currentTimeMillis();
            c.this.f0.e = pointF;
            c.this.f0.c = c.this.getCenter();
            c.this.f0.d = pointF;
            c.this.f0.f = c.this.a(pointF);
            c.this.f0.g = new PointF(paddingLeft, paddingTop);
            c.this.f0.h = this.d;
            c.this.f0.i = this.g;
            c.this.f0.j = this.e;
            c.this.f0.k = this.f;
            c.this.f0.l = System.currentTimeMillis();
            c.this.f0.m = this.i;
            PointF pointF3 = this.c;
            if (pointF3 != null) {
                float f = pointF3.x - (c.this.f0.c.x * b);
                float f2 = this.c.y - (c.this.f0.c.y * b);
                j jVar = new j(b, new PointF(f, f2), aVar);
                c.this.a(true, jVar);
                c.this.f0.g = new PointF(this.c.x + (jVar.b.x - f), this.c.y + (jVar.b.y - f2));
            }
            c.this.invalidate();
        }
    }

    public static class f extends AsyncTask<Void, Void, Integer> {
        private final WeakReference<c> a;
        private final WeakReference<Context> b;
        private final WeakReference<com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.c>> c;
        private final Uri d;
        private final boolean e;
        private Bitmap f;
        private Exception g;

        public f(c cVar, Context context, com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.c> bVar, Uri uri, boolean z10) {
            this.a = new WeakReference<>(cVar);
            this.b = new WeakReference<>(context);
            this.c = new WeakReference<>(bVar);
            this.d = uri;
            this.e = z10;
        }

        @Override
        public Integer doInBackground(Void... voidArr) {
            try {
                String uri = this.d.toString();
                Context context = this.b.get();
                com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.c> bVar = this.c.get();
                c cVar = this.a.get();
                if (context == null || bVar == null || cVar == null) {
                    return null;
                }
                cVar.a("BitmapLoadTask.doInBackground", new Object[0]);
                this.f = bVar.a().a(context, this.d);
                return Integer.valueOf(cVar.a(context, uri));
            } catch (Exception e) {
                Log.e("SubsamplingScaleIV", "Failed to load bitmap", e);
                this.g = e;
                return null;
            } catch (OutOfMemoryError e2) {
                Log.e("SubsamplingScaleIV", "Failed to load bitmap - OutOfMemoryError", e2);
                this.g = new RuntimeException(e2);
                return null;
            }
        }

        @Override
        public void onPostExecute(Integer num) {
            c cVar = this.a.get();
            if (cVar != null) {
                Bitmap bitmap = this.f;
                if (bitmap != null && num != null) {
                    if (this.e) {
                        cVar.a(bitmap);
                        return;
                    } else {
                        cVar.a(bitmap, num.intValue(), false);
                        return;
                    }
                }
                if (this.g == null || cVar.i0 == null) {
                    return;
                }
                if (this.e) {
                    cVar.i0.a(this.g);
                } else {
                    cVar.i0.c(this.g);
                }
            }
        }
    }

    public interface g {
        void a();

        void b();

        void c();
    }

    public interface h {
        void a();

        void a(Exception exc);

        void b();

        void b(Exception exc);

        void c();

        void c(Exception exc);
    }

    public interface i {
        void a(float f, int i);

        void a(PointF pointF, int i);
    }

    public static class j {
        private float a;
        private final PointF b;

        private j(float f, PointF pointF) {
            this.a = f;
            this.b = pointF;
        }

        public j(float f, PointF pointF, a aVar) {
            this(f, pointF);
        }
    }

    public static class k {
        private Rect a;
        private int b;
        private Bitmap c;
        private boolean d;
        private boolean e;
        private Rect f;
        private Rect g;

        private k() {
        }

        public k(a aVar) {
            this();
        }
    }

    public static class l extends AsyncTask<Void, Void, Bitmap> {
        private final WeakReference<c> a;
        private final WeakReference<com.finogeeks.lib.applet.externallib.subscaleview.decoder.d> b;
        private final WeakReference<k> c;
        private Exception d;

        public l(c cVar, com.finogeeks.lib.applet.externallib.subscaleview.decoder.d dVar, k kVar) {
            this.a = new WeakReference<>(cVar);
            this.b = new WeakReference<>(dVar);
            this.c = new WeakReference<>(kVar);
            kVar.d = true;
        }

        @Override
        public Bitmap doInBackground(Void... voidArr) {
            try {
                c cVar = this.a.get();
                com.finogeeks.lib.applet.externallib.subscaleview.decoder.d dVar = this.b.get();
                k kVar = this.c.get();
                if (dVar == null || kVar == null || cVar == null || !dVar.a() || !kVar.e) {
                    if (kVar == null) {
                        return null;
                    }
                    kVar.d = false;
                    return null;
                }
                cVar.a("TileLoadTask.doInBackground, tile.sRect=%s, tile.sampleSize=%d", kVar.a, Integer.valueOf(kVar.b));
                cVar.R.readLock().lock();
                try {
                    if (!dVar.a()) {
                        kVar.d = false;
                        cVar.R.readLock().unlock();
                        return null;
                    }
                    cVar.a(kVar.a, kVar.g);
                    if (cVar.I != null) {
                        kVar.g.offset(cVar.I.left, cVar.I.top);
                    }
                    Bitmap a = dVar.a(kVar.g, kVar.b);
                    cVar.R.readLock().unlock();
                    return a;
                } catch (Throwable th2) {
                    cVar.R.readLock().unlock();
                    throw th2;
                }
            } catch (Exception e) {
                Log.e("SubsamplingScaleIV", "Failed to decode tile", e);
                this.d = e;
                return null;
            } catch (OutOfMemoryError e2) {
                Log.e("SubsamplingScaleIV", "Failed to decode tile - OutOfMemoryError", e2);
                this.d = new RuntimeException(e2);
                return null;
            }
        }

        @Override
        public void onPostExecute(Bitmap bitmap) {
            c cVar = this.a.get();
            k kVar = this.c.get();
            if (cVar == null || kVar == null) {
                return;
            }
            if (bitmap != null) {
                kVar.c = bitmap;
                kVar.d = false;
                cVar.j();
            } else {
                if (this.d == null || cVar.i0 == null) {
                    return;
                }
                cVar.i0.b(this.d);
            }
        }
    }

    public static class m extends AsyncTask<Void, Void, int[]> {
        private final WeakReference<c> a;
        private final WeakReference<Context> b;
        private final WeakReference<com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.d>> c;
        private final Uri d;
        private com.finogeeks.lib.applet.externallib.subscaleview.decoder.d e;
        private Exception f;

        public m(c cVar, Context context, com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.d> bVar, Uri uri) {
            this.a = new WeakReference<>(cVar);
            this.b = new WeakReference<>(context);
            this.c = new WeakReference<>(bVar);
            this.d = uri;
        }

        @Override
        public void onPostExecute(int[] iArr) {
            c cVar = this.a.get();
            if (cVar != null) {
                com.finogeeks.lib.applet.externallib.subscaleview.decoder.d dVar = this.e;
                if (dVar != null && iArr != null && iArr.length == 3) {
                    cVar.a(dVar, iArr[0], iArr[1], iArr[2]);
                } else {
                    if (this.f == null || cVar.i0 == null) {
                        return;
                    }
                    cVar.i0.c(this.f);
                }
            }
        }

        @Override
        public int[] doInBackground(Void... voidArr) {
            try {
                String uri = this.d.toString();
                Context context = this.b.get();
                com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.d> bVar = this.c.get();
                c cVar = this.a.get();
                if (context == null || bVar == null || cVar == null) {
                    return null;
                }
                cVar.a("TilesInitTask.doInBackground", new Object[0]);
                com.finogeeks.lib.applet.externallib.subscaleview.decoder.d a = bVar.a();
                this.e = a;
                Point a2 = a.a(context, this.d);
                int i = a2.x;
                int i2 = a2.y;
                int a3 = cVar.a(context, uri);
                if (cVar.I != null) {
                    cVar.I.left = Math.max(0, cVar.I.left);
                    cVar.I.top = Math.max(0, cVar.I.top);
                    cVar.I.right = Math.min(i, cVar.I.right);
                    cVar.I.bottom = Math.min(i2, cVar.I.bottom);
                    i = cVar.I.width();
                    i2 = cVar.I.height();
                }
                return new int[]{i, i2, a3};
            } catch (Exception e) {
                Log.e("SubsamplingScaleIV", "Failed to initialise bitmap decoder", e);
                this.f = e;
                return null;
            }
        }
    }

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

    public c(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        int resourceId;
        String string;
        this.h = 0;
        this.i = 2.0f;
        this.j = i();
        this.k = -1;
        this.l = 1;
        this.m = 1;
        this.n = Integer.MAX_VALUE;
        this.o = Integer.MAX_VALUE;
        this.p = AsyncTask.THREAD_POOL_EXECUTOR;
        this.q = true;
        this.r = true;
        this.s = true;
        this.t = true;
        this.u = 1.0f;
        this.v = 1;
        this.w = 500;
        this.R = new ReentrantReadWriteLock(true);
        this.S = new com.finogeeks.lib.applet.externallib.subscaleview.decoder.a(SkiaImageDecoder.class);
        this.T = new com.finogeeks.lib.applet.externallib.subscaleview.decoder.a(SkiaImageRegionDecoder.class);
        this.t0 = new float[8];
        this.u0 = new float[8];
        this.v0 = getResources().getDisplayMetrics().density;
        setMinimumDpi(160);
        setDoubleTapZoomDpi(160);
        setMinimumTileDpi(320);
        setGestureDetector(context);
        this.l0 = new Handler(new a());
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.styleable.SubsamplingScaleImageView);
            int i2 = R.styleable.SubsamplingScaleImageView_fin_applet_assetName;
            if (obtainStyledAttributes.hasValue(i2) && (string = obtainStyledAttributes.getString(i2)) != null && string.length() > 0) {
                setImage(com.finogeeks.lib.applet.externallib.subscaleview.a.a(string).j());
            }
            int i3 = R.styleable.SubsamplingScaleImageView_fin_applet_src;
            if (obtainStyledAttributes.hasValue(i3) && (resourceId = obtainStyledAttributes.getResourceId(i3, 0)) > 0) {
                setImage(com.finogeeks.lib.applet.externallib.subscaleview.a.a(resourceId).j());
            }
            int i4 = R.styleable.SubsamplingScaleImageView_fin_applet_panEnabled;
            if (obtainStyledAttributes.hasValue(i4)) {
                setPanEnabled(obtainStyledAttributes.getBoolean(i4, true));
            }
            int i5 = R.styleable.SubsamplingScaleImageView_fin_applet_zoomEnabled;
            if (obtainStyledAttributes.hasValue(i5)) {
                setZoomEnabled(obtainStyledAttributes.getBoolean(i5, true));
            }
            int i6 = R.styleable.SubsamplingScaleImageView_fin_applet_quickScaleEnabled;
            if (obtainStyledAttributes.hasValue(i6)) {
                setQuickScaleEnabled(obtainStyledAttributes.getBoolean(i6, true));
            }
            int i7 = R.styleable.SubsamplingScaleImageView_fin_applet_tileBackgroundColor;
            if (obtainStyledAttributes.hasValue(i7)) {
                setTileBackgroundColor(obtainStyledAttributes.getColor(i7, Color.argb(0, 0, 0, 0)));
            }
            obtainStyledAttributes.recycle();
        }
        this.W = TypedValue.applyDimension(1, 20.0f, context.getResources().getDisplayMetrics());
    }

    private float a(float f2, float f3, float f4, float f5) {
        float f6 = f2 - f3;
        float f7 = f4 - f5;
        return (float) Math.sqrt((f6 * f6) + (f7 * f7));
    }

    private float a(int i2, long j2, float f2, float f3, long j3) {
        if (i2 == 1) {
            return b(j2, f2, f3, j3);
        }
        if (i2 == 2) {
            return a(j2, f2, f3, j3);
        }
        throw new IllegalStateException("Unexpected easing type: " + i2);
    }

    private float a(long j2, float f2, float f3, long j3) {
        float f4;
        float f5 = j2 / (j3 / 2.0f);
        if (f5 < 1.0f) {
            f4 = (f3 / 2.0f) * f5;
        } else {
            float f6 = f5 - 1.0f;
            f4 = (-f3) / 2.0f;
            f5 = (f6 * (f6 - 2.0f)) - 1.0f;
        }
        return (f4 * f5) + f2;
    }

    private int a(float f2) {
        int round;
        if (this.k > 0) {
            DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
            f2 *= this.k / ((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f);
        }
        int m2 = (int) (m() * f2);
        int l2 = (int) (l() * f2);
        if (m2 == 0 || l2 == 0) {
            return 32;
        }
        int i2 = 1;
        if (l() > l2 || m() > m2) {
            round = Math.round(l() / l2);
            int round2 = Math.round(m() / m2);
            if (round >= round2) {
                round = round2;
            }
        } else {
            round = 1;
        }
        while (true) {
            int i3 = i2 * 2;
            if (i3 >= round) {
                return i2;
            }
            i2 = i3;
        }
    }

    private int a(int i2) {
        return (int) (this.v0 * i2);
    }

    public int a(Context context, String str) {
        int i2 = 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 i3 = cursor.getInt(0);
                        if (!w0.contains(Integer.valueOf(i3)) || i3 == -1) {
                            Log.w("SubsamplingScaleIV", "Unsupported orientation: " + i3);
                        } else {
                            i2 = i3;
                        }
                    }
                    if (cursor != null) {
                        cursor.close();
                    }
                } finally {
                }
            } catch (Exception unused) {
                Log.w("SubsamplingScaleIV", "Could not get orientation of image from media store");
                if (cursor != null) {
                    cursor.close();
                }
            }
        } else if (str.startsWith("file:///") && !str.startsWith("file:///android_asset/")) {
            try {
                int a2 = new com.finogeeks.lib.applet.externallib.subscaleview.d.a(str.substring(7)).a("Orientation", 1);
                if (a2 != 1 && a2 != 0) {
                    if (a2 == 6) {
                        return 90;
                    }
                    if (a2 == 3) {
                        return 180;
                    }
                    if (a2 == 8) {
                        return 270;
                    }
                    Log.w("SubsamplingScaleIV", "Unsupported EXIF orientation: " + a2);
                }
                return 0;
            } catch (Exception unused2) {
                Log.w("SubsamplingScaleIV", "Could not get EXIF orientation of image");
            }
        }
        return i2;
    }

    @NonNull
    private Point a(Canvas canvas) {
        return new Point(Math.min(canvas.getMaximumBitmapWidth(), this.n), Math.min(canvas.getMaximumBitmapHeight(), this.o));
    }

    @NonNull
    private PointF a(float f2, float f3, float f4) {
        int paddingLeft = getPaddingLeft() + (((getWidth() - getPaddingRight()) - getPaddingLeft()) / 2);
        int paddingTop = getPaddingTop() + (((getHeight() - getPaddingBottom()) - getPaddingTop()) / 2);
        if (this.q0 == null) {
            this.q0 = new j(0.0f, new PointF(0.0f, 0.0f), null);
        }
        this.q0.a = f4;
        this.q0.b.set(paddingLeft - (f2 * f4), paddingTop - (f3 * f4));
        a(true, this.q0);
        return this.q0.b;
    }

    @NonNull
    public PointF a(float f2, float f3, float f4, @NonNull PointF pointF) {
        PointF a2 = a(f2, f3, f4);
        pointF.set(((getPaddingLeft() + (((getWidth() - getPaddingRight()) - getPaddingLeft()) / 2)) - a2.x) / f4, ((getPaddingTop() + (((getHeight() - getPaddingBottom()) - getPaddingTop()) / 2)) - a2.y) / f4);
        return pointF;
    }

    private void a(float f2, PointF pointF, int i2) {
        i iVar = this.j0;
        if (iVar != null) {
            float f3 = this.x;
            if (f3 != f2) {
                iVar.a(f3, i2);
            }
        }
        if (this.j0 == null || this.f84z.equals(pointF)) {
            return;
        }
        this.j0.a(getCenter(), i2);
    }

    public synchronized void a(Bitmap bitmap) {
        try {
            a("onPreviewLoaded", new Object[0]);
            if (this.a == null && !this.h0) {
                Rect rect = this.J;
                if (rect != null) {
                    this.a = Bitmap.createBitmap(bitmap, rect.left, rect.top, rect.width(), this.J.height());
                } else {
                    this.a = bitmap;
                }
                this.b = true;
                if (f()) {
                    invalidate();
                    requestLayout();
                }
                return;
            }
            bitmap.recycle();
        } catch (Throwable th2) {
            throw th2;
        }
    }

    public synchronized void a(Bitmap bitmap, int i2, boolean z10) {
        h hVar;
        try {
            a("onImageLoaded", new Object[0]);
            int i3 = this.F;
            if (i3 > 0) {
                if (this.G > 0) {
                    if (i3 == bitmap.getWidth()) {
                        if (this.G != bitmap.getHeight()) {
                        }
                    }
                    d(false);
                }
            }
            Bitmap bitmap2 = this.a;
            if (bitmap2 != null && !this.c) {
                bitmap2.recycle();
            }
            if (this.a != null && this.c && (hVar = this.i0) != null) {
                hVar.b();
            }
            this.b = false;
            this.c = z10;
            this.a = bitmap;
            this.F = bitmap.getWidth();
            this.G = bitmap.getHeight();
            this.H = i2;
            boolean f2 = f();
            boolean e2 = e();
            if (f2 || e2) {
                invalidate();
                requestLayout();
            }
        } catch (Throwable th2) {
            throw th2;
        }
    }

    private synchronized void a(@NonNull Point point) {
        Throwable th2;
        try {
            try {
                a("initialiseBaseLayer maxTileDimensions=%dx%d", Integer.valueOf(point.x), Integer.valueOf(point.y));
                j jVar = new j(0.0f, new PointF(0.0f, 0.0f), null);
                this.q0 = jVar;
                a(true, jVar);
                int a2 = a(this.q0.a);
                this.e = a2;
                if (a2 > 1) {
                    try {
                        this.e = a2 / 2;
                    } catch (Throwable th3) {
                        th2 = th3;
                        throw th2;
                    }
                }
                if (this.e != 1 || this.I != null || m() >= point.x || l() >= point.y) {
                    b(point);
                    Iterator<k> it = this.f.get(Integer.valueOf(this.e)).iterator();
                    while (it.hasNext()) {
                        a(new l(this, this.Q, it.next()));
                    }
                    b(true);
                } else {
                    this.Q.b();
                    this.Q = null;
                    a(new f(this, getContext(), this.S, this.d, false));
                }
            } catch (Throwable th4) {
                th = th4;
                th2 = th;
                throw th2;
            }
        } catch (Throwable th5) {
            th = th5;
            th2 = th;
            throw th2;
        }
    }

    public void a(PointF pointF, PointF pointF2) {
        if (!this.r) {
            PointF pointF3 = this.E;
            if (pointF3 != null) {
                pointF.x = pointF3.x;
                pointF.y = pointF3.y;
            } else {
                pointF.x = m() / 2;
                pointF.y = l() / 2;
            }
        }
        float min = Math.min(this.i, this.u);
        float f2 = this.x;
        boolean z10 = ((double) f2) <= ((double) min) * 0.9d || f2 == this.j;
        if (!z10) {
            min = i();
        }
        int i2 = this.v;
        if (i2 == 3) {
            a(min, pointF);
        } else if (i2 == 2 || !z10 || !this.r) {
            new e(this, min, pointF, (a) null).a(false).a(this.w).b(4).a();
        } else if (i2 == 1) {
            new e(this, min, pointF, pointF2, null).a(false).a(this.w).b(4).a();
        }
        invalidate();
    }

    public void a(Rect rect, Rect rect2) {
        if (getRequiredRotation() == 0) {
            rect2.set(rect);
            return;
        }
        if (getRequiredRotation() == 90) {
            int i2 = rect.top;
            int i3 = this.G;
            rect2.set(i2, i3 - rect.right, rect.bottom, i3 - rect.left);
        } else if (getRequiredRotation() != 180) {
            int i4 = this.F;
            rect2.set(i4 - rect.bottom, rect.left, i4 - rect.top, rect.right);
        } else {
            int i5 = this.F;
            int i6 = i5 - rect.right;
            int i7 = this.G;
            rect2.set(i6, i7 - rect.bottom, i5 - rect.left, i7 - rect.top);
        }
    }

    private void a(AsyncTask<Void, Void, ?> asyncTask) {
        asyncTask.executeOnExecutor(this.p, new Void[0]);
    }

    private void a(com.finogeeks.lib.applet.externallib.subscaleview.b bVar) {
        if (bVar == null || !w0.contains(Integer.valueOf(bVar.b()))) {
            return;
        }
        this.h = bVar.b();
        this.C = Float.valueOf(bVar.c());
        this.D = bVar.a();
        invalidate();
    }

    public synchronized void a(com.finogeeks.lib.applet.externallib.subscaleview.decoder.d dVar, int i2, int i3, int i4) {
        int i5;
        int i6;
        int i7;
        try {
            a("onTilesInited sWidth=%d, sHeight=%d, sOrientation=%d", Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(this.h));
            int i8 = this.F;
            if (i8 > 0 && (i7 = this.G) > 0 && (i8 != i2 || i7 != i3)) {
                d(false);
                Bitmap bitmap = this.a;
                if (bitmap != null) {
                    if (!this.c) {
                        bitmap.recycle();
                    }
                    this.a = null;
                    h hVar = this.i0;
                    if (hVar != null && this.c) {
                        hVar.b();
                    }
                    this.b = false;
                    this.c = false;
                }
            }
            this.Q = dVar;
            this.F = i2;
            this.G = i3;
            this.H = i4;
            f();
            if (!e() && (i5 = this.n) > 0 && i5 != Integer.MAX_VALUE && (i6 = this.o) > 0 && i6 != Integer.MAX_VALUE && getWidth() > 0 && getHeight() > 0) {
                a(new Point(this.n, this.o));
            }
            invalidate();
            requestLayout();
        } catch (Throwable th2) {
            throw th2;
        }
    }

    public void a(String str, Object... objArr) {
        if (this.g) {
            Log.d("SubsamplingScaleIV", String.format(str, objArr));
        }
    }

    private void a(boolean z10) {
        boolean z11;
        float f2 = 0.0f;
        if (this.f84z == null) {
            this.f84z = new PointF(0.0f, 0.0f);
            z11 = true;
        } else {
            z11 = false;
        }
        if (this.q0 == null) {
            this.q0 = new j(f2, new PointF(0.0f, 0.0f), null);
        }
        this.q0.a = this.x;
        this.q0.b.set(this.f84z);
        a(z10, this.q0);
        this.x = this.q0.a;
        this.f84z.set(this.q0.b);
        if (!z11 || this.m == 4) {
            return;
        }
        this.f84z.set(a(m() / 2, l() / 2, this.x));
    }

    public void a(boolean z10, j jVar) {
        float max;
        int max2;
        float max3;
        if (this.l == 2 && a()) {
            z10 = false;
        }
        PointF pointF = jVar.b;
        float b2 = b(jVar.a);
        float m2 = m() * b2;
        float l2 = l() * b2;
        if (this.l == 3 && a()) {
            pointF.x = Math.max(pointF.x, (getWidth() / 2) - m2);
            pointF.y = Math.max(pointF.y, (getHeight() / 2) - l2);
        } else if (z10) {
            pointF.x = Math.max(pointF.x, getWidth() - m2);
            pointF.y = Math.max(pointF.y, getHeight() - l2);
        } else {
            pointF.x = Math.max(pointF.x, -m2);
            pointF.y = Math.max(pointF.y, -l2);
        }
        float paddingLeft = (getPaddingLeft() > 0 || getPaddingRight() > 0) ? getPaddingLeft() / (getPaddingLeft() + getPaddingRight()) : 0.5f;
        float paddingTop = (getPaddingTop() > 0 || getPaddingBottom() > 0) ? getPaddingTop() / (getPaddingTop() + getPaddingBottom()) : 0.5f;
        if (this.l == 3 && a()) {
            max = Math.max(0, getWidth() / 2);
            max2 = Math.max(0, getHeight() / 2);
        } else {
            if (z10) {
                max = Math.max(0.0f, (getWidth() - m2) * paddingLeft);
                max3 = Math.max(0.0f, (getHeight() - l2) * paddingTop);
                pointF.x = Math.min(pointF.x, max);
                pointF.y = Math.min(pointF.y, max3);
                jVar.a = b2;
            }
            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);
        jVar.a = b2;
    }

    private void a(float[] fArr, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9) {
        fArr[0] = f2;
        fArr[1] = f3;
        fArr[2] = f4;
        fArr[3] = f5;
        fArr[4] = f6;
        fArr[5] = f7;
        fArr[6] = f8;
        fArr[7] = f9;
    }

    private boolean a(@androidx.annotation.NonNull android.view.MotionEvent r11) {
        throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.externallib.subscaleview.c.a(android.view.MotionEvent):boolean");
    }

    private boolean a(k kVar) {
        return e(0.0f) <= ((float) kVar.a.right) && ((float) kVar.a.left) <= e((float) getWidth()) && f(0.0f) <= ((float) kVar.a.bottom) && ((float) kVar.a.top) <= f((float) getHeight());
    }

    public float b(float f2) {
        return Math.min(this.i, Math.max(i(), f2));
    }

    private float b(long j2, float f2, float f3, long j3) {
        float f4 = j2 / j3;
        return ((-f3) * f4 * (f4 - 2.0f)) + f2;
    }

    private void b(Point point) {
        int i2 = 1;
        a("initialiseTileMap maxTileDimensions=%dx%d", Integer.valueOf(point.x), Integer.valueOf(point.y));
        this.f = new LinkedHashMap();
        int i3 = this.e;
        int i4 = 1;
        int i5 = 1;
        while (true) {
            int m2 = m() / i4;
            int l2 = l() / i5;
            int i6 = m2 / i3;
            int i7 = l2 / i3;
            while (true) {
                if (i6 + i4 + i2 > point.x || (i6 > getWidth() * 1.25d && i3 < this.e)) {
                    i4 += i2;
                    m2 = m() / i4;
                    i6 = m2 / i3;
                }
            }
            while (true) {
                if (i7 + i5 + i2 > point.y || (i7 > getHeight() * 1.25d && i3 < this.e)) {
                    i5 += i2;
                    l2 = l() / i5;
                    i7 = l2 / i3;
                }
            }
            ArrayList arrayList = new ArrayList(i4 * i5);
            int i8 = 0;
            while (i8 < i4) {
                int i9 = 0;
                while (i9 < i5) {
                    k kVar = new k(null);
                    kVar.b = i3;
                    kVar.e = i3 == this.e;
                    kVar.a = new Rect(i8 * m2, i9 * l2, i8 == i4 + (-1) ? m() : (i8 + 1) * m2, i9 == i5 + (-1) ? l() : (i9 + 1) * l2);
                    kVar.f = new Rect(0, 0, 0, 0);
                    kVar.g = new Rect(kVar.a);
                    arrayList.add(kVar);
                    i9++;
                }
                i8++;
            }
            this.f.put(Integer.valueOf(i3), arrayList);
            i2 = 1;
            if (i3 == 1) {
                return;
            } else {
                i3 /= 2;
            }
        }
    }

    private void b(@NonNull Rect rect, @NonNull Rect rect2) {
        rect2.set((int) c(rect.left), (int) d(rect.top), (int) c(rect.right), (int) d(rect.bottom));
    }

    private void b(boolean z10) {
        if (this.Q == null || this.f == null) {
            return;
        }
        int min = Math.min(this.e, a(this.x));
        Iterator<Map.Entry<Integer, List<k>>> it = this.f.entrySet().iterator();
        while (it.hasNext()) {
            for (k kVar : it.next().getValue()) {
                if (kVar.b < min || (kVar.b > min && kVar.b != this.e)) {
                    kVar.e = false;
                    if (kVar.c != null) {
                        kVar.c.recycle();
                        kVar.c = null;
                    }
                }
                if (kVar.b == min) {
                    if (a(kVar)) {
                        kVar.e = true;
                        if (!kVar.d && kVar.c == null && z10) {
                            a(new l(this, this.Q, kVar));
                        }
                    } else if (kVar.b != this.e) {
                        kVar.e = false;
                        if (kVar.c != null) {
                            kVar.c.recycle();
                            kVar.c = null;
                        }
                    }
                } else if (kVar.b == this.e) {
                    kVar.e = true;
                }
            }
        }
    }

    private float c(float f2) {
        PointF pointF = this.f84z;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f2 * this.x) + pointF.x;
    }

    private void c(boolean z10) {
        ViewParent parent = getParent();
        if (parent != null) {
            parent.requestDisallowInterceptTouchEvent(z10);
        }
    }

    private float d(float f2) {
        PointF pointF = this.f84z;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f2 * this.x) + pointF.y;
    }

    private void d(boolean z10) {
        h hVar;
        a("reset newImage=" + z10, new Object[0]);
        this.x = 0.0f;
        this.f83y = 0.0f;
        this.f84z = null;
        this.A = null;
        this.B = null;
        this.C = Float.valueOf(0.0f);
        this.D = null;
        this.E = null;
        this.K = false;
        this.L = false;
        this.M = false;
        this.N = 0;
        this.e = 0;
        this.U = null;
        this.V = 0.0f;
        this.a0 = 0.0f;
        this.b0 = false;
        this.d0 = null;
        this.c0 = null;
        this.e0 = null;
        this.f0 = null;
        this.q0 = null;
        this.r0 = null;
        this.s0 = null;
        if (z10) {
            this.d = null;
            this.R.writeLock().lock();
            try {
                com.finogeeks.lib.applet.externallib.subscaleview.decoder.d dVar = this.Q;
                if (dVar != null) {
                    dVar.b();
                    this.Q = null;
                }
                this.R.writeLock().unlock();
                Bitmap bitmap = this.a;
                if (bitmap != null && !this.c) {
                    bitmap.recycle();
                }
                if (this.a != null && this.c && (hVar = this.i0) != null) {
                    hVar.b();
                }
                this.F = 0;
                this.G = 0;
                this.H = 0;
                this.I = null;
                this.J = null;
                this.g0 = false;
                this.h0 = false;
                this.a = null;
                this.b = false;
                this.c = false;
            } catch (Throwable th2) {
                this.R.writeLock().unlock();
                throw th2;
            }
        }
        Map<Integer, List<k>> map = this.f;
        if (map != null) {
            Iterator<Map.Entry<Integer, List<k>>> it = map.entrySet().iterator();
            while (it.hasNext()) {
                for (k kVar : it.next().getValue()) {
                    kVar.e = false;
                    if (kVar.c != null) {
                        kVar.c.recycle();
                        kVar.c = null;
                    }
                }
            }
            this.f = null;
        }
        setGestureDetector(getContext());
    }

    private float e(float f2) {
        PointF pointF = this.f84z;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f2 - pointF.x) / this.x;
    }

    private boolean e() {
        boolean h2 = h();
        if (!this.h0 && h2) {
            k();
            this.h0 = true;
            b();
            h hVar = this.i0;
            if (hVar != null) {
                hVar.c();
            }
        }
        return h2;
    }

    private float f(float f2) {
        PointF pointF = this.f84z;
        if (pointF == null) {
            return Float.NaN;
        }
        return (f2 - pointF.y) / this.x;
    }

    private boolean f() {
        boolean z10 = getWidth() > 0 && getHeight() > 0 && this.F > 0 && this.G > 0 && (this.a != null || h());
        if (!this.g0 && z10) {
            k();
            this.g0 = true;
            c();
            h hVar = this.i0;
            if (hVar != null) {
                hVar.a();
            }
        }
        return z10;
    }

    private void g() {
        if (this.m0 == null) {
            Paint paint = new Paint();
            this.m0 = paint;
            paint.setAntiAlias(true);
            this.m0.setFilterBitmap(true);
            this.m0.setDither(true);
        }
        if ((this.n0 == null || this.o0 == null) && this.g) {
            Paint paint2 = new Paint();
            this.n0 = paint2;
            paint2.setTextSize(a(12));
            this.n0.setColor(-65281);
            this.n0.setStyle(Paint.Style.FILL);
            Paint paint3 = new Paint();
            this.o0 = paint3;
            paint3.setColor(-65281);
            this.o0.setStyle(Paint.Style.STROKE);
            this.o0.setStrokeWidth(a(1));
        }
    }

    public static Bitmap.Config getPreferredBitmapConfig() {
        return B0;
    }

    private int getRequiredRotation() {
        int i2 = this.h;
        return i2 == -1 ? this.H : i2;
    }

    private boolean h() {
        boolean z10 = true;
        if (this.a != null && !this.b) {
            return true;
        }
        Map<Integer, List<k>> map = this.f;
        if (map == null) {
            return false;
        }
        for (Map.Entry<Integer, List<k>> entry : map.entrySet()) {
            if (entry.getKey().intValue() == this.e) {
                for (k kVar : entry.getValue()) {
                    if (kVar.d || kVar.c == null) {
                        z10 = false;
                    }
                }
            }
        }
        return z10;
    }

    private float i() {
        int paddingBottom = getPaddingBottom() + getPaddingTop();
        int paddingLeft = getPaddingLeft() + getPaddingRight();
        int i2 = this.m;
        if (i2 == 2 || i2 == 4) {
            return Math.max((getWidth() - paddingLeft) / m(), (getHeight() - paddingBottom) / l());
        }
        if (i2 == 3) {
            float f2 = this.j;
            if (f2 > 0.0f) {
                return f2;
            }
        }
        return Math.min((getWidth() - paddingLeft) / m(), (getHeight() - paddingBottom) / l());
    }

    public synchronized void j() {
        Bitmap bitmap;
        try {
            a("onTileLoaded", new Object[0]);
            f();
            e();
            if (h() && (bitmap = this.a) != null) {
                if (!this.c) {
                    bitmap.recycle();
                }
                this.a = null;
                h hVar = this.i0;
                if (hVar != null && this.c) {
                    hVar.b();
                }
                this.b = false;
                this.c = false;
            }
            invalidate();
        } catch (Throwable th2) {
            throw th2;
        }
    }

    private void k() {
        Float f2;
        if (getWidth() == 0 || getHeight() == 0 || this.F <= 0 || this.G <= 0) {
            return;
        }
        if (this.D != null && (f2 = this.C) != null) {
            this.x = f2.floatValue();
            if (this.f84z == null) {
                this.f84z = new PointF();
            }
            this.f84z.x = (getWidth() / 2) - (this.x * this.D.x);
            this.f84z.y = (getHeight() / 2) - (this.x * this.D.y);
            this.D = null;
            this.C = null;
            a(true);
            b(true);
        }
        a(false);
    }

    private int l() {
        int requiredRotation = getRequiredRotation();
        return (requiredRotation == 90 || requiredRotation == 270) ? this.F : this.G;
    }

    private int m() {
        int requiredRotation = getRequiredRotation();
        return (requiredRotation == 90 || requiredRotation == 270) ? this.G : this.F;
    }

    public void setGestureDetector(Context context) {
        this.O = new GestureDetector(context, new b(context));
        this.P = new GestureDetector(context, new C0101c());
    }

    public static void setPreferredBitmapConfig(Bitmap.Config config) {
        B0 = config;
    }

    @Nullable
    public final PointF a(float f2, float f3) {
        return b(f2, f3, new PointF());
    }

    @Nullable
    public final PointF a(float f2, float f3, @NonNull PointF pointF) {
        if (this.f84z == null) {
            return null;
        }
        pointF.set(c(f2), d(f3));
        return pointF;
    }

    @Nullable
    public final PointF a(PointF pointF) {
        return a(pointF.x, pointF.y, new PointF());
    }

    public final void a(float f2, @Nullable PointF pointF) {
        this.f0 = null;
        this.C = Float.valueOf(f2);
        this.D = pointF;
        this.E = pointF;
        invalidate();
    }

    public final void a(@NonNull com.finogeeks.lib.applet.externallib.subscaleview.a aVar, com.finogeeks.lib.applet.externallib.subscaleview.a aVar2, com.finogeeks.lib.applet.externallib.subscaleview.b bVar) {
        if (aVar == null) {
            throw new NullPointerException("imageSource must not be null");
        }
        d(true);
        if (bVar != null) {
            a(bVar);
        }
        if (aVar2 != null) {
            if (aVar.a() != null) {
                throw new IllegalArgumentException("Preview image cannot be used when a bitmap is provided for the main image");
            }
            if (aVar.e() <= 0 || aVar.c() <= 0) {
                throw new IllegalArgumentException("Preview image cannot be used unless dimensions are provided for the main image");
            }
            this.F = aVar.e();
            this.G = aVar.c();
            this.J = aVar2.d();
            if (aVar2.a() != null) {
                this.c = aVar2.h();
                a(aVar2.a());
            } else {
                Uri g2 = aVar2.g();
                if (g2 == null && aVar2.b() != null) {
                    g2 = Uri.parse("android.resource://" + getContext().getPackageName() + "/" + aVar2.b());
                }
                a(new f(this, getContext(), this.S, g2, true));
            }
        }
        if (aVar.a() != null && aVar.d() != null) {
            a(Bitmap.createBitmap(aVar.a(), aVar.d().left, aVar.d().top, aVar.d().width(), aVar.d().height()), 0, false);
            return;
        }
        if (aVar.a() != null) {
            a(aVar.a(), 0, aVar.h());
            return;
        }
        this.I = aVar.d();
        Uri g3 = aVar.g();
        this.d = g3;
        if (g3 == null && aVar.b() != null) {
            this.d = Uri.parse("android.resource://" + getContext().getPackageName() + "/" + aVar.b());
        }
        if (aVar.f() || this.I != null) {
            a(new m(this, getContext(), this.T, this.d));
        } else {
            a(new f(this, getContext(), this.S, this.d, false));
        }
    }

    public final void a(@NonNull com.finogeeks.lib.applet.externallib.subscaleview.a aVar, com.finogeeks.lib.applet.externallib.subscaleview.b bVar) {
        a(aVar, (com.finogeeks.lib.applet.externallib.subscaleview.a) null, bVar);
    }

    public final boolean a() {
        return this.g0;
    }

    @Nullable
    public final PointF b(float f2, float f3, @NonNull PointF pointF) {
        if (this.f84z == null) {
            return null;
        }
        pointF.set(e(f2), f(f3));
        return pointF;
    }

    @Nullable
    public final PointF b(PointF pointF) {
        return b(pointF.x, pointF.y, new PointF());
    }

    public void b() {
    }

    public void c() {
    }

    public final int getAppliedOrientation() {
        return getRequiredRotation();
    }

    @Nullable
    public final PointF getCenter() {
        return a(getWidth() / 2, getHeight() / 2);
    }

    public float getMaxScale() {
        return this.i;
    }

    public final float getMinScale() {
        return i();
    }

    public final int getOrientation() {
        return this.h;
    }

    public final int getSHeight() {
        return this.G;
    }

    public final int getSWidth() {
        return this.F;
    }

    public final float getScale() {
        return this.x;
    }

    @Nullable
    public final com.finogeeks.lib.applet.externallib.subscaleview.b getState() {
        if (this.f84z == null || this.F <= 0 || this.G <= 0) {
            return null;
        }
        return new com.finogeeks.lib.applet.externallib.subscaleview.b(getScale(), getCenter(), getOrientation());
    }

    @Override
    public void onDraw(Canvas canvas) {
        int i2;
        char c;
        float f2;
        int i3;
        super.onDraw(canvas);
        g();
        if (this.F == 0 || this.G == 0 || getWidth() == 0 || getHeight() == 0) {
            return;
        }
        if (this.f == null && this.Q != null) {
            a(a(canvas));
        }
        if (f()) {
            k();
            d dVar = this.f0;
            if (dVar != null && dVar.f != null) {
                float f3 = this.x;
                if (this.B == null) {
                    this.B = new PointF(0.0f, 0.0f);
                }
                this.B.set(this.f84z);
                long currentTimeMillis = System.currentTimeMillis() - this.f0.l;
                boolean z10 = currentTimeMillis > this.f0.h;
                long min = Math.min(currentTimeMillis, this.f0.h);
                this.x = a(this.f0.j, min, this.f0.a, this.f0.b - this.f0.a, this.f0.h);
                float a2 = a(this.f0.j, min, this.f0.f.x, this.f0.g.x - this.f0.f.x, this.f0.h);
                float a3 = a(this.f0.j, min, this.f0.f.y, this.f0.g.y - this.f0.f.y, this.f0.h);
                this.f84z.x -= c(this.f0.d.x) - a2;
                this.f84z.y -= d(this.f0.d.y) - a3;
                a(z10 || this.f0.a == this.f0.b);
                a(f3, this.B, this.f0.k);
                b(z10);
                if (z10) {
                    if (this.f0.m != null) {
                        try {
                            this.f0.m.a();
                        } catch (Exception e2) {
                            Log.w("SubsamplingScaleIV", "Error thrown by animation listener", e2);
                        }
                    }
                    this.f0 = null;
                }
                invalidate();
            }
            if (this.f == null || !h()) {
                i2 = 5;
                c = 0;
                if (this.a != null) {
                    float f4 = this.x;
                    if (this.b) {
                        float width = f4 * (this.F / r0.getWidth());
                        f4 = this.x * (this.G / this.a.getHeight());
                        f2 = width;
                    } else {
                        f2 = f4;
                    }
                    if (this.r0 == null) {
                        this.r0 = new Matrix();
                    }
                    this.r0.reset();
                    this.r0.postScale(f2, f4);
                    this.r0.postRotate(getRequiredRotation());
                    Matrix matrix = this.r0;
                    PointF pointF = this.f84z;
                    matrix.postTranslate(pointF.x, pointF.y);
                    if (getRequiredRotation() == 180) {
                        Matrix matrix2 = this.r0;
                        float f5 = this.x;
                        matrix2.postTranslate(this.F * f5, f5 * this.G);
                    } else if (getRequiredRotation() == 90) {
                        this.r0.postTranslate(this.x * this.G, 0.0f);
                    } else if (getRequiredRotation() == 270) {
                        this.r0.postTranslate(0.0f, this.x * this.F);
                    }
                    if (this.p0 != null) {
                        if (this.s0 == null) {
                            this.s0 = new RectF();
                        }
                        this.s0.set(0.0f, 0.0f, this.b ? this.a.getWidth() : this.F, this.b ? this.a.getHeight() : this.G);
                        this.r0.mapRect(this.s0);
                        canvas.drawRect(this.s0, this.p0);
                    }
                    canvas.drawBitmap(this.a, this.r0, this.m0);
                }
            } else {
                int min2 = Math.min(this.e, a(this.x));
                boolean z11 = false;
                for (Map.Entry<Integer, List<k>> entry : this.f.entrySet()) {
                    if (entry.getKey().intValue() == min2) {
                        for (k kVar : entry.getValue()) {
                            if (kVar.e && (kVar.d || kVar.c == null)) {
                                z11 = true;
                            }
                        }
                    }
                }
                for (Map.Entry<Integer, List<k>> entry2 : this.f.entrySet()) {
                    if (entry2.getKey().intValue() == min2 || z11) {
                        for (k kVar2 : entry2.getValue()) {
                            b(kVar2.a, kVar2.f);
                            if (kVar2.d || kVar2.c == null) {
                                i3 = 5;
                                if (kVar2.d && this.g) {
                                    canvas.drawText("LOADING", kVar2.f.left + a(5), kVar2.f.top + a(35), this.n0);
                                }
                            } else {
                                if (this.p0 != null) {
                                    canvas.drawRect(kVar2.f, this.p0);
                                }
                                if (this.r0 == null) {
                                    this.r0 = new Matrix();
                                }
                                this.r0.reset();
                                i3 = 5;
                                a(this.t0, 0.0f, 0.0f, kVar2.c.getWidth(), 0.0f, kVar2.c.getWidth(), kVar2.c.getHeight(), 0.0f, kVar2.c.getHeight());
                                if (getRequiredRotation() == 0) {
                                    a(this.u0, kVar2.f.left, kVar2.f.top, kVar2.f.right, kVar2.f.top, kVar2.f.right, kVar2.f.bottom, kVar2.f.left, kVar2.f.bottom);
                                } else if (getRequiredRotation() == 90) {
                                    a(this.u0, kVar2.f.right, kVar2.f.top, kVar2.f.right, kVar2.f.bottom, kVar2.f.left, kVar2.f.bottom, kVar2.f.left, kVar2.f.top);
                                } else if (getRequiredRotation() == 180) {
                                    a(this.u0, kVar2.f.right, kVar2.f.bottom, kVar2.f.left, kVar2.f.bottom, kVar2.f.left, kVar2.f.top, kVar2.f.right, kVar2.f.top);
                                } else if (getRequiredRotation() == 270) {
                                    a(this.u0, kVar2.f.left, kVar2.f.bottom, kVar2.f.left, kVar2.f.top, kVar2.f.right, kVar2.f.top, kVar2.f.right, kVar2.f.bottom);
                                }
                                this.r0.setPolyToPoly(this.t0, 0, this.u0, 0, 4);
                                canvas.drawBitmap(kVar2.c, this.r0, this.m0);
                                if (this.g) {
                                    canvas.drawRect(kVar2.f, this.o0);
                                }
                            }
                            if (kVar2.e && this.g) {
                                canvas.drawText("ISS " + kVar2.b + " RECT " + kVar2.a.top + "," + kVar2.a.left + "," + kVar2.a.bottom + "," + kVar2.a.right, kVar2.f.left + a(i3), kVar2.f.top + a(15), this.n0);
                            }
                        }
                    }
                }
                i2 = 5;
                c = 0;
            }
            if (this.g) {
                StringBuilder sb = new StringBuilder();
                sb.append("Scale: ");
                Locale locale = Locale.ENGLISH;
                Object[] objArr = new Object[1];
                objArr[c] = Float.valueOf(this.x);
                sb.append(String.format(locale, "%.2f", objArr));
                sb.append(" (");
                Object[] objArr2 = new Object[1];
                objArr2[c] = Float.valueOf(i());
                sb.append(String.format(locale, "%.2f", objArr2));
                sb.append(" - ");
                Object[] objArr3 = new Object[1];
                objArr3[c] = Float.valueOf(this.i);
                sb.append(String.format(locale, "%.2f", objArr3));
                sb.append(")");
                canvas.drawText(sb.toString(), a(i2), a(15), this.n0);
                StringBuilder sb2 = new StringBuilder();
                sb2.append("Translate: ");
                Object[] objArr4 = new Object[1];
                objArr4[c] = Float.valueOf(this.f84z.x);
                sb2.append(String.format(locale, "%.2f", objArr4));
                sb2.append(":");
                Object[] objArr5 = new Object[1];
                objArr5[c] = Float.valueOf(this.f84z.y);
                sb2.append(String.format(locale, "%.2f", objArr5));
                canvas.drawText(sb2.toString(), a(i2), a(30), this.n0);
                PointF center = getCenter();
                StringBuilder sb3 = new StringBuilder();
                sb3.append("Source center: ");
                Object[] objArr6 = new Object[1];
                objArr6[c] = Float.valueOf(center.x);
                sb3.append(String.format(locale, "%.2f", objArr6));
                sb3.append(":");
                Object[] objArr7 = new Object[1];
                objArr7[c] = Float.valueOf(center.y);
                sb3.append(String.format(locale, "%.2f", objArr7));
                canvas.drawText(sb3.toString(), a(i2), a(45), this.n0);
                d dVar2 = this.f0;
                if (dVar2 != null) {
                    PointF a4 = a(dVar2.c);
                    PointF a5 = a(this.f0.e);
                    PointF a6 = a(this.f0.d);
                    canvas.drawCircle(a4.x, a4.y, a(10), this.o0);
                    this.o0.setColor(-65536);
                    canvas.drawCircle(a5.x, a5.y, a(20), this.o0);
                    this.o0.setColor(-16776961);
                    canvas.drawCircle(a6.x, a6.y, a(25), this.o0);
                    this.o0.setColor(-16711681);
                    canvas.drawCircle(getWidth() / 2, getHeight() / 2, a(30), this.o0);
                }
                if (this.U != null) {
                    this.o0.setColor(-65536);
                    PointF pointF2 = this.U;
                    canvas.drawCircle(pointF2.x, pointF2.y, a(20), this.o0);
                }
                if (this.d0 != null) {
                    this.o0.setColor(-16776961);
                    canvas.drawCircle(c(this.d0.x), d(this.d0.y), a(35), this.o0);
                }
                if (this.e0 != null && this.M) {
                    this.o0.setColor(-16711681);
                    PointF pointF3 = this.e0;
                    canvas.drawCircle(pointF3.x, pointF3.y, a(30), this.o0);
                }
                this.o0.setColor(-65281);
            }
        }
    }

    @Override
    public void onMeasure(int i2, int i3) {
        int mode = View.MeasureSpec.getMode(i2);
        int mode2 = View.MeasureSpec.getMode(i3);
        int size = View.MeasureSpec.getSize(i2);
        int size2 = View.MeasureSpec.getSize(i3);
        boolean z10 = mode != 1073741824;
        boolean z11 = mode2 != 1073741824;
        if (this.F > 0 && this.G > 0) {
            if (z10 && z11) {
                size = m();
                size2 = l();
            } else if (z11) {
                size2 = (int) ((l() / m()) * size);
            } else if (z10) {
                size = (int) ((m() / l()) * size2);
            }
        }
        setMeasuredDimension(Math.max(size, getSuggestedMinimumWidth()), Math.max(size2, getSuggestedMinimumHeight()));
    }

    @Override
    public void onSizeChanged(int i2, int i3, int i4, int i5) {
        a("onSizeChanged %dx%d -> %dx%d", Integer.valueOf(i4), Integer.valueOf(i5), Integer.valueOf(i2), Integer.valueOf(i3));
        PointF center = getCenter();
        if (!this.g0 || center == null) {
            return;
        }
        this.f0 = null;
        this.C = Float.valueOf(this.x);
        this.D = center;
    }

    @Override
    public boolean onTouchEvent(@NonNull MotionEvent motionEvent) {
        GestureDetector gestureDetector;
        d dVar = this.f0;
        if (dVar != null && !dVar.i) {
            c(true);
            return true;
        }
        d dVar2 = this.f0;
        if (dVar2 != null && dVar2.m != null) {
            try {
                this.f0.m.b();
            } catch (Exception e2) {
                Log.w("SubsamplingScaleIV", "Error thrown by animation listener", e2);
            }
        }
        this.f0 = null;
        if (this.f84z == null) {
            GestureDetector gestureDetector2 = this.P;
            if (gestureDetector2 != null) {
                gestureDetector2.onTouchEvent(motionEvent);
            }
            return true;
        }
        if (!this.M && ((gestureDetector = this.O) == null || gestureDetector.onTouchEvent(motionEvent))) {
            this.K = false;
            this.L = false;
            this.N = 0;
            return true;
        }
        if (this.A == null) {
            this.A = new PointF(0.0f, 0.0f);
        }
        if (this.B == null) {
            this.B = new PointF(0.0f, 0.0f);
        }
        if (this.U == null) {
            this.U = new PointF(0.0f, 0.0f);
        }
        float f2 = this.x;
        this.B.set(this.f84z);
        boolean a2 = a(motionEvent);
        a(f2, this.B, 2);
        return a2 || super.onTouchEvent(motionEvent);
    }

    public final void setBitmapDecoderClass(@NonNull Class<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.c> cls) {
        if (cls == null) {
            throw new IllegalArgumentException("Decoder class cannot be set to null");
        }
        this.S = new com.finogeeks.lib.applet.externallib.subscaleview.decoder.a(cls);
    }

    public final void setBitmapDecoderFactory(@NonNull com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.c> bVar) {
        if (bVar == null) {
            throw new IllegalArgumentException("Decoder factory cannot be set to null");
        }
        this.S = bVar;
    }

    public final void setDebug(boolean z10) {
        this.g = z10;
    }

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

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

    public final void setDoubleTapZoomScale(float f2) {
        this.u = f2;
    }

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

    public void setEagerLoadingEnabled(boolean z10) {
        this.q = z10;
    }

    public void setExecutor(@NonNull Executor executor) {
        if (executor == null) {
            throw new NullPointerException("Executor must not be null");
        }
        this.p = executor;
    }

    public final void setImage(@NonNull com.finogeeks.lib.applet.externallib.subscaleview.a aVar) {
        a(aVar, (com.finogeeks.lib.applet.externallib.subscaleview.a) null, (com.finogeeks.lib.applet.externallib.subscaleview.b) null);
    }

    public final void setMaxScale(float f2) {
        this.i = f2;
    }

    public void setMaxTileSize(int i2) {
        this.n = i2;
        this.o = i2;
    }

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

    public final void setMinScale(float f2) {
        this.j = f2;
    }

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

    public final void setMinimumScaleType(int i2) {
        if (!A0.contains(Integer.valueOf(i2))) {
            throw new IllegalArgumentException("Invalid scale type: " + i2);
        }
        this.m = i2;
        if (a()) {
            a(true);
            invalidate();
        }
    }

    public void setMinimumTileDpi(int i2) {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        this.k = (int) Math.min((displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f, i2);
        if (a()) {
            d(false);
            invalidate();
        }
    }

    public void setOnImageEventListener(h hVar) {
        this.i0 = hVar;
    }

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

    public void setOnStateChangedListener(i iVar) {
        this.j0 = iVar;
    }

    public final void setOrientation(int i2) {
        if (!w0.contains(Integer.valueOf(i2))) {
            throw new IllegalArgumentException("Invalid orientation: " + i2);
        }
        this.h = i2;
        d(false);
        invalidate();
        requestLayout();
    }

    public final void setPanEnabled(boolean z10) {
        PointF pointF;
        this.r = z10;
        if (z10 || (pointF = this.f84z) == null) {
            return;
        }
        pointF.x = (getWidth() / 2) - (this.x * (m() / 2));
        this.f84z.y = (getHeight() / 2) - (this.x * (l() / 2));
        if (a()) {
            b(true);
            invalidate();
        }
    }

    public final void setPanLimit(int i2) {
        if (!f82z0.contains(Integer.valueOf(i2))) {
            throw new IllegalArgumentException("Invalid pan limit: " + i2);
        }
        this.l = i2;
        if (a()) {
            a(true);
            invalidate();
        }
    }

    public final void setQuickScaleEnabled(boolean z10) {
        this.t = z10;
    }

    public final void setRegionDecoderClass(@NonNull Class<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.d> cls) {
        if (cls == null) {
            throw new IllegalArgumentException("Decoder class cannot be set to null");
        }
        this.T = new com.finogeeks.lib.applet.externallib.subscaleview.decoder.a(cls);
    }

    public final void setRegionDecoderFactory(@NonNull com.finogeeks.lib.applet.externallib.subscaleview.decoder.b<? extends com.finogeeks.lib.applet.externallib.subscaleview.decoder.d> bVar) {
        if (bVar == null) {
            throw new IllegalArgumentException("Decoder factory cannot be set to null");
        }
        this.T = bVar;
    }

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

    public final void setZoomEnabled(boolean z10) {
        this.s = z10;
    }
}