what-the-bank/sources/com/github/barteksc/pdfviewer/PDFView.java

813 lines
24 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.github.barteksc.pdfviewer;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.HandlerThread;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.RelativeLayout;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.shockwave.pdfium.PdfiumCore;
import com.shockwave.pdfium.util.Size;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import o.C12957fMe;
import o.C13256fVZ;
import o.C1641aJz;
import o.C16773rCR;
import o.Cci;
import o.EDi;
import o.Gyh;
import o.IUh;
import o.InterfaceC0428GiV;
import o.InterfaceC15766iSi;
import o.InterfaceC16338nbk;
import o.InterfaceC6105cIs;
import o.Lni;
import o.MGF;
import o.MIO;
import o.MoQ;
import o.TRg;
import o.Vla;
import o.Xsy;
import o.ZAW;
import o.jPn;
import o.msi;
import o.uFI;
import o.vuB;
import o.xFW;
/* loaded from: classes.dex */
public class PDFView extends RelativeLayout {
public int A;
public int B;
public int C;
public uFI D;
private PaintFlagsDrawFilter E;
private Paint F;
public IeS G;
public boolean H;
public float I;
private boolean J;
private EDi K;
private boolean L;
private boolean M;
private List<Integer> N;
private Paint O;
private boolean P;
private RVV Q;
private PdfiumCore R;
private C16773rCR S;
private HBt U;
public boolean a;
public boolean b;
public C13256fVZ c;
public C1641aJz d;
public boolean e;
public int f;
public Gyh g;
public int h;
public float i;
public float j;
public boolean k;
public boolean l;
public boolean m;
boolean n;
/* renamed from: o, reason: collision with root package name */
public xFW f6459o;
public float p;
public IUh q;
public float r;
boolean s;
public float t;
public boolean u;
public boolean v;
public Cci w;
public HandlerThread x;
public msi y;
public int z;
/* loaded from: classes.dex */
public enum IeS {
DEFAULT,
LOADED,
SHOWN,
ERROR
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public enum RVV {
NONE,
START,
END
}
public PDFView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.r = 1.0f;
this.t = 1.75f;
this.p = 3.0f;
this.Q = RVV.NONE;
this.j = BitmapDescriptorFactory.HUE_RED;
this.i = BitmapDescriptorFactory.HUE_RED;
this.I = 1.0f;
this.P = true;
this.G = IeS.DEFAULT;
this.g = new Gyh();
this.q = IUh.WIDTH;
this.m = false;
this.h = 0;
this.H = true;
this.l = true;
this.k = true;
this.J = false;
this.L = true;
this.s = false;
this.e = false;
this.b = false;
this.v = false;
this.n = true;
this.E = new PaintFlagsDrawFilter(0, 3);
this.B = 0;
this.C = 0;
this.z = 0;
this.A = 0;
this.a = false;
this.u = true;
this.N = new ArrayList(10);
this.M = false;
this.x = new HandlerThread("PDF renderer");
if (isInEditMode()) {
return;
}
this.c = new C13256fVZ();
C1641aJz c1641aJz = new C1641aJz(this);
this.d = c1641aJz;
this.f6459o = new xFW(this, c1641aJz);
this.S = new C16773rCR(this);
this.O = new Paint();
Paint paint = new Paint();
this.F = paint;
paint.setStyle(Paint.Style.STROKE);
this.R = new PdfiumCore(context);
setWillNotDraw(false);
}
public final void b(int i) {
float f;
msi msiVar = this.y;
if (msiVar == null) {
return;
}
int d = msiVar.d(i);
if (d == 0) {
f = this.C;
} else {
msi msiVar2 = this.y;
f = -(msiVar2.a(d) < 0 ? BitmapDescriptorFactory.HUE_RED : msiVar2.j.get(d).floatValue() * this.I);
}
if (this.H) {
e(this.j, f, true);
} else {
e(f, this.i, true);
}
a(d);
}
private void a(int i) {
if (this.P) {
return;
}
this.f = this.y.d(i);
c();
int i2 = this.y.f;
}
public void setPositionOffset(float f) {
setPositionOffset(f, true);
}
public void setNightMode(boolean z) {
this.J = z;
if (z) {
this.O.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(new float[]{-1.0f, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 255.0f, BitmapDescriptorFactory.HUE_RED, -1.0f, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 255.0f, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, -1.0f, BitmapDescriptorFactory.HUE_RED, 255.0f, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 1.0f, BitmapDescriptorFactory.HUE_RED})));
} else {
this.O.setColorFilter(null);
}
}
public final void a() {
this.U = null;
this.d.a();
this.f6459o.e = false;
Cci cci = this.w;
if (cci != null) {
cci.e = false;
this.w.removeMessages(1);
}
EDi eDi = this.K;
if (eDi != null) {
eDi.cancel(true);
}
this.c.b();
msi msiVar = this.y;
if (msiVar != null) {
msiVar.c();
this.y = null;
}
this.w = null;
this.D = null;
this.s = false;
this.i = BitmapDescriptorFactory.HUE_RED;
this.j = BitmapDescriptorFactory.HUE_RED;
this.I = 1.0f;
this.P = true;
this.g = new Gyh();
this.G = IeS.DEFAULT;
}
@Override // android.view.View
public void computeScroll() {
super.computeScroll();
if (isInEditMode()) {
return;
}
C1641aJz c1641aJz = this.d;
if (c1641aJz.b.computeScrollOffset()) {
c1641aJz.e.e(c1641aJz.b.getCurrX(), c1641aJz.b.getCurrY(), true);
c1641aJz.e.d();
} else if (c1641aJz.c) {
c1641aJz.c = false;
c1641aJz.e.c();
uFI ufi = c1641aJz.e.D;
c1641aJz.e.e();
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
a();
HandlerThread handlerThread = this.x;
if (handlerThread != null) {
handlerThread.quitSafely();
this.x = null;
}
super.onDetachedFromWindow();
}
@Override // android.view.View
protected void onSizeChanged(int i, int i2, int i3, int i4) {
float f;
float f2;
this.M = true;
HBt hBt = this.U;
if (hBt != null) {
hBt.c();
}
if (isInEditMode() || this.G != IeS.SHOWN) {
return;
}
float f3 = (-this.j) + (i3 * 0.5f);
float f4 = -this.i;
float f5 = i4;
if (!this.H) {
f = f3 / (this.y.b * this.I);
msi msiVar = this.y;
f2 = (msiVar.c ? msiVar.d : msiVar.e).b;
} else {
msi msiVar2 = this.y;
f = f3 / (msiVar2.c ? msiVar2.d : msiVar2.e).a;
f2 = this.y.b * this.I;
}
float f6 = (f4 + (f5 * 0.5f)) / f2;
this.d.a();
this.y.c(new Size(i, i2));
if (this.H) {
float f7 = -f;
msi msiVar3 = this.y;
this.j = (f7 * (msiVar3.c ? msiVar3.d : msiVar3.e).a) + (i * 0.5f);
this.i = ((-f6) * this.y.b * this.I) + (i2 * 0.5f);
} else {
this.j = ((-f) * this.y.b * this.I) + (i * 0.5f);
float f8 = -f6;
msi msiVar4 = this.y;
this.i = (f8 * (msiVar4.c ? msiVar4.d : msiVar4.e).b) + (i2 * 0.5f);
}
e(this.j, this.i, true);
d();
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
if (isInEditMode()) {
return;
}
if (this.n) {
canvas.setDrawFilter(this.E);
}
Drawable background = getBackground();
if (background == null) {
canvas.drawColor(this.J ? -16777216 : -1);
} else {
background.draw(canvas);
}
if (!this.P && this.G == IeS.SHOWN) {
float f = this.j;
float f2 = this.i;
canvas.translate(f, f2);
Iterator<Xsy> it = this.c.e().iterator();
while (it.hasNext()) {
Gp_(canvas, it.next());
}
Iterator<Xsy> it2 = this.c.c().iterator();
while (it2.hasNext()) {
Gp_(canvas, it2.next());
Vla vla = this.g.a;
}
Iterator<Integer> it3 = this.N.iterator();
while (it3.hasNext()) {
Gq_(canvas, it3.next().intValue(), this.g.a);
}
this.N.clear();
Gq_(canvas, this.f, this.g.e);
canvas.translate(-f, -f2);
}
}
public final void c() {
Cci cci;
if (this.y == null || (cci = this.w) == null) {
return;
}
cci.removeMessages(1);
this.c.a();
this.S.e();
invalidate();
}
public final int a(float f, float f2) {
boolean z = this.H;
if (z) {
f = f2;
}
float height = z ? getHeight() : getWidth();
if (f > -1.0f) {
return 0;
}
if (f >= (-(this.y.b * this.I)) + height + 1.0f) {
return this.y.b(-(f - (height / 2.0f)), this.I);
}
return this.y.f - 1;
}
/* loaded from: classes.dex */
public class HBt {
private IUh A;
private int[] B;
private boolean C;
private String D;
private uFI F;
private PDFView H;
public boolean a;
public int b;
public boolean c;
public int d;
public int e;
public int f;
public int g;
public boolean h;
private boolean i;
private boolean j;
private boolean k;
private boolean l;
private boolean m;
private ZAW n;
/* renamed from: o, reason: collision with root package name */
private final Lni f6460o;
private InterfaceC0428GiV p;
private InterfaceC16338nbk q;
private Vla r;
private TRg s;
private Vla t;
private MoQ u;
private InterfaceC6105cIs v;
private InterfaceC15766iSi w;
private vuB x;
private jPn y;
private boolean z;
public /* synthetic */ HBt(PDFView pDFView, Lni lni, byte b) {
this(pDFView, lni);
}
private HBt(PDFView pDFView, Lni lni) {
this.H = pDFView;
this.B = null;
this.c = true;
this.a = true;
this.n = new MGF(pDFView);
this.d = 0;
this.h = false;
this.i = false;
this.D = null;
this.F = null;
this.j = true;
this.e = 0;
this.g = 0;
this.f = 0;
this.b = 0;
this.m = false;
this.A = IUh.WIDTH;
this.k = false;
this.C = false;
this.z = false;
this.l = false;
this.f6460o = lni;
}
public final void c() {
if (!this.H.M) {
this.H.U = this;
return;
}
this.H.a();
this.H.g.b = null;
this.H.g.d = null;
this.H.g.e = null;
this.H.g.a = null;
this.H.g.j = null;
this.H.g.i = null;
this.H.g.g = null;
this.H.g.n = null;
this.H.g.f = null;
this.H.g.h = null;
this.H.g.c = this.n;
this.H.setSwipeEnabled(this.c);
this.H.setNightMode(false);
this.H.k = this.a;
this.H.h = 0;
this.H.H = true;
this.H.b = false;
this.H.D = null;
this.H.n = this.j;
PDFView.a(this.H, this.e);
PDFView.c(this.H, this.g);
PDFView.b(this.H, this.f);
PDFView.e(this.H, this.b);
this.H.a = false;
this.H.q = this.A;
this.H.m = false;
this.H.setPageSnap(false);
this.H.setPageFling(false);
PDFView.a(this.H, this.f6460o);
}
}
static /* synthetic */ void e(PDFView pDFView, int i) {
pDFView.A = (int) TypedValue.applyDimension(1, i, pDFView.getContext().getResources().getDisplayMetrics());
}
static /* synthetic */ void a(PDFView pDFView, Lni lni) {
if (!pDFView.P) {
throw new IllegalStateException("Don't call load on a PDF View without recycling it first.");
}
pDFView.P = false;
EDi eDi = new EDi(lni, null, null, pDFView, pDFView.R);
pDFView.K = eDi;
eDi.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
static /* synthetic */ void a(PDFView pDFView, int i) {
pDFView.B = (int) TypedValue.applyDimension(1, i, pDFView.getContext().getResources().getDisplayMetrics());
}
static /* synthetic */ void c(PDFView pDFView, int i) {
pDFView.C = (int) TypedValue.applyDimension(1, i, pDFView.getContext().getResources().getDisplayMetrics());
}
static /* synthetic */ void b(PDFView pDFView, int i) {
pDFView.z = (int) TypedValue.applyDimension(1, i, pDFView.getContext().getResources().getDisplayMetrics());
}
private void Gp_(Canvas canvas, Xsy xsy) {
C12957fMe c12957fMe;
float floatValue;
float f;
RectF rectF = xsy.b;
Bitmap bitmap = xsy.d;
if (bitmap.isRecycled()) {
return;
}
msi msiVar = this.y;
int i = xsy.c;
if (msiVar.a(i) < 0) {
c12957fMe = new C12957fMe(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
} else {
c12957fMe = msiVar.g.get(i);
}
if (!this.H) {
msi msiVar2 = this.y;
int i2 = xsy.c;
floatValue = msiVar2.a(i2) < 0 ? 0.0f : msiVar2.j.get(i2).floatValue() * this.I;
msi msiVar3 = this.y;
f = (((msiVar3.c ? msiVar3.d : msiVar3.e).b - c12957fMe.b) * this.I) / 2.0f;
} else {
msi msiVar4 = this.y;
int i3 = xsy.c;
f = msiVar4.a(i3) < 0 ? 0.0f : msiVar4.j.get(i3).floatValue() * this.I;
msi msiVar5 = this.y;
floatValue = (((msiVar5.c ? msiVar5.d : msiVar5.e).a - c12957fMe.a) * this.I) / 2.0f;
}
canvas.translate(floatValue, f);
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
float f2 = rectF.left * c12957fMe.a * this.I;
float f3 = rectF.top * c12957fMe.b * this.I;
RectF rectF2 = new RectF((int) f2, (int) f3, (int) (f2 + (rectF.width() * c12957fMe.a * this.I)), (int) (f3 + (rectF.height() * c12957fMe.b * this.I)));
float f4 = this.j + floatValue;
float f5 = this.i + f;
if (rectF2.left + f4 >= getWidth() || f4 + rectF2.right <= BitmapDescriptorFactory.HUE_RED || rectF2.top + f5 >= getHeight() || f5 + rectF2.bottom <= BitmapDescriptorFactory.HUE_RED) {
canvas.translate(-floatValue, -f);
} else {
canvas.drawBitmap(bitmap, rect, rectF2, this.O);
canvas.translate(-floatValue, -f);
}
}
private void Gq_(Canvas canvas, int i, Vla vla) {
float floatValue;
float f;
C12957fMe c12957fMe;
if (vla != null) {
if (!this.H) {
msi msiVar = this.y;
floatValue = msiVar.a(i) < 0 ? 0.0f : msiVar.j.get(i).floatValue() * this.I;
f = 0.0f;
} else {
msi msiVar2 = this.y;
f = msiVar2.a(i) < 0 ? 0.0f : msiVar2.j.get(i).floatValue() * this.I;
floatValue = 0.0f;
}
canvas.translate(floatValue, f);
msi msiVar3 = this.y;
if (msiVar3.a(i) < 0) {
c12957fMe = new C12957fMe(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
} else {
c12957fMe = msiVar3.g.get(i);
}
float f2 = c12957fMe.a;
float f3 = c12957fMe.b;
canvas.translate(-floatValue, -f);
}
}
@Override // android.view.View
public boolean canScrollHorizontally(int i) {
msi msiVar = this.y;
if (msiVar == null) {
return true;
}
if (this.H) {
if (i < 0 && this.j < BitmapDescriptorFactory.HUE_RED) {
return true;
}
if (i > 0) {
return this.j + ((msiVar.c ? msiVar.d : msiVar.e).a * this.I) > ((float) getWidth());
}
return false;
}
if (i < 0 && this.j < BitmapDescriptorFactory.HUE_RED) {
return true;
}
if (i > 0) {
return this.j + (msiVar.b * this.I) > ((float) getWidth());
}
return false;
}
@Override // android.view.View
public boolean canScrollVertically(int i) {
msi msiVar = this.y;
if (msiVar == null) {
return true;
}
if (this.H) {
if (i < 0 && this.i < BitmapDescriptorFactory.HUE_RED) {
return true;
}
if (i > 0) {
return this.i + (msiVar.b * this.I) > ((float) getHeight());
}
return false;
}
if (i < 0 && this.i < BitmapDescriptorFactory.HUE_RED) {
return true;
}
if (i > 0) {
return this.i + ((msiVar.c ? msiVar.d : msiVar.e).b * this.I) > ((float) getHeight());
}
return false;
}
private float b() {
float f;
float f2;
int width;
if (this.H) {
f = -this.i;
f2 = this.y.b * this.I;
width = getHeight();
} else {
f = -this.j;
f2 = this.y.b * this.I;
width = getWidth();
}
float f3 = f / (f2 - width);
if (f3 <= BitmapDescriptorFactory.HUE_RED) {
return BitmapDescriptorFactory.HUE_RED;
}
if (f3 >= 1.0f) {
return 1.0f;
}
return f3;
}
public final void d() {
float f;
int width;
if (this.y.f == 0) {
return;
}
if (this.H) {
f = this.i;
width = getHeight();
} else {
f = this.j;
width = getWidth();
}
int b = this.y.b(-(f - (width / 2.0f)), this.I);
if (b >= 0 && b <= this.y.f - 1 && b != this.f) {
a(b);
} else {
c();
}
}
/* JADX WARN: Removed duplicated region for block: B:12:0x0050 */
/* JADX WARN: Removed duplicated region for block: B:15:0x0076 */
/* JADX WARN: Removed duplicated region for block: B:19:0x007c */
/* JADX WARN: Removed duplicated region for block: B:23:0x0058 */
/* JADX WARN: Removed duplicated region for block: B:45:0x00d5 */
/* JADX WARN: Removed duplicated region for block: B:48:0x00fb */
/* JADX WARN: Removed duplicated region for block: B:49:0x0100 */
/* JADX WARN: Removed duplicated region for block: B:53:0x00dd */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void e(float r5, float r6, boolean r7) {
/*
Method dump skipped, instructions count: 280
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.github.barteksc.pdfviewer.PDFView.e(float, float, boolean):void");
}
public final void e() {
msi msiVar;
int a;
MIO d;
if (!this.L || (msiVar = this.y) == null || msiVar.f == 0 || (d = d((a = a(this.j, this.i)))) == MIO.NONE) {
return;
}
float b = b(a, d);
if (this.H) {
this.d.a(this.i, -b);
} else {
this.d.e(this.j, -b);
}
}
public void setPositionOffset(float f, boolean z) {
if (this.H) {
e(this.j, ((-(this.y.b * this.I)) + getHeight()) * f, z);
} else {
e(((-(this.y.b * this.I)) + getWidth()) * f, this.i, z);
}
d();
}
public final void Gr_(float f, PointF pointF) {
float f2 = f / this.I;
this.I = f;
float f3 = this.j;
float f4 = this.i;
e((f3 * f2) + (pointF.x - (pointF.x * f2)), (f4 * f2) + (pointF.y - (pointF.y * f2)), true);
}
public final MIO d(int i) {
C12957fMe c12957fMe;
float f;
if (!this.L || i < 0) {
return MIO.NONE;
}
float f2 = this.H ? this.i : this.j;
msi msiVar = this.y;
float f3 = -(msiVar.a(i) < 0 ? 0.0f : msiVar.j.get(i).floatValue() * this.I);
int height = this.H ? getHeight() : getWidth();
msi msiVar2 = this.y;
float f4 = this.I;
if (msiVar2.a(i) < 0) {
c12957fMe = new C12957fMe(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
} else {
c12957fMe = msiVar2.g.get(i);
}
if (msiVar2.c) {
f = c12957fMe.b;
} else {
f = c12957fMe.a;
}
float f5 = f * f4;
float f6 = height;
if (f6 >= f5) {
return MIO.CENTER;
}
if (f2 >= f3) {
return MIO.START;
}
if (f3 - f5 > f2 - f6) {
return MIO.END;
}
return MIO.NONE;
}
public final float b(int i, MIO mio) {
C12957fMe c12957fMe;
float f;
float f2;
msi msiVar = this.y;
float floatValue = msiVar.a(i) < 0 ? 0.0f : msiVar.j.get(i).floatValue() * this.I;
float height = this.H ? getHeight() : getWidth();
msi msiVar2 = this.y;
float f3 = this.I;
if (msiVar2.a(i) < 0) {
c12957fMe = new C12957fMe(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
} else {
c12957fMe = msiVar2.g.get(i);
}
if (msiVar2.c) {
f = c12957fMe.b;
} else {
f = c12957fMe.a;
}
float f4 = f * f3;
if (mio == MIO.CENTER) {
f2 = floatValue - (height / 2.0f);
f4 /= 2.0f;
} else {
if (mio != MIO.END) {
return floatValue;
}
f2 = floatValue - height;
}
return f2 + f4;
}
public void setSwipeEnabled(boolean z) {
this.l = z;
}
public void setPageSnap(boolean z) {
this.L = z;
}
public void setPageFling(boolean z) {
this.u = z;
}
public void setMinZoom(float f) {
this.r = f;
}
public void setMidZoom(float f) {
this.t = f;
}
public void setMaxZoom(float f) {
this.p = f;
}
}