discord-jadx/app/src/main/java/b/f/l/b/c.java

280 lines
8.4 KiB
Java

package b.f.l.b;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.view.MotionEvent;
import b.f.d.e.a;
import b.f.l.a.a;
import b.f.l.a.b;
import b.f.l.b.e;
import com.discord.models.domain.ModelAuditLogEntry;
import com.facebook.samples.zoomable.ZoomableDraweeView;
import java.util.Objects;
/* compiled from: DefaultZoomableController */
public class c implements e, b.a {
public b a;
/* renamed from: b reason: collision with root package name */
public e.a f648b = null;
public boolean c = false;
public final RectF d = new RectF();
public final RectF e = new RectF();
public final RectF f = new RectF();
public final Matrix g = new Matrix();
public final Matrix h = new Matrix();
public final Matrix i = new Matrix();
public final float[] j = new float[9];
public final RectF k = new RectF();
public boolean l;
static {
new RectF(0.0f, 0.0f, 1.0f, 1.0f);
}
public c(b bVar) {
this.a = bVar;
bVar.f645b = this;
}
public static boolean l(int i, int i2) {
return (i & i2) != 0;
}
@Override // b.f.l.b.e
public boolean a() {
this.h.getValues(this.j);
float[] fArr = this.j;
fArr[0] = fArr[0] - 1.0f;
fArr[4] = fArr[4] - 1.0f;
fArr[8] = fArr[8] - 1.0f;
for (int i = 0; i < 9; i++) {
if (Math.abs(this.j[i]) > 0.001f) {
return false;
}
}
return true;
}
@Override // b.f.l.a.b.a
public void b(b bVar) {
float f;
a.i(c.class, "onGestureUpdate");
Matrix matrix = this.h;
b bVar2 = this.a;
matrix.set(this.g);
b.f.l.a.a aVar = bVar2.a;
if (aVar.f644b < 2) {
f = 1.0f;
} else {
float[] fArr = aVar.d;
float f2 = fArr[1] - fArr[0];
float[] fArr2 = aVar.e;
float f3 = fArr2[1] - fArr2[0];
float[] fArr3 = aVar.f;
float f4 = fArr3[1] - fArr3[0];
float[] fArr4 = aVar.g;
float f5 = fArr4[1] - fArr4[0];
f = ((float) Math.hypot((double) f4, (double) f5)) / ((float) Math.hypot((double) f2, (double) f3));
}
matrix.postScale(f, f, bVar2.b(), bVar2.c());
b.f.l.a.a aVar2 = bVar2.a;
float a = bVar2.a(aVar2.f, aVar2.f644b);
b.f.l.a.a aVar3 = bVar2.a;
float a2 = a - bVar2.a(aVar3.d, aVar3.f644b);
b.f.l.a.a aVar4 = bVar2.a;
float a3 = bVar2.a(aVar4.g, aVar4.f644b);
b.f.l.a.a aVar5 = bVar2.a;
matrix.postTranslate(a2, a3 - bVar2.a(aVar5.e, aVar5.f644b));
boolean g = g(matrix, 7) | f(matrix, bVar2.b(), bVar2.c(), 7) | false;
i();
if (g) {
this.a.d();
}
this.l = g;
}
@Override // b.f.l.a.b.a
public void c(b bVar) {
a.i(c.class, "onGestureBegin");
this.g.set(this.h);
RectF rectF = this.f;
float f = rectF.left;
RectF rectF2 = this.d;
this.l = !(f < rectF2.left - 0.001f && rectF.top < rectF2.top - 0.001f && rectF.right > rectF2.right + 0.001f && rectF.bottom > rectF2.bottom + 0.001f);
}
public final float d(float f, float f2, float f3, float f4, float f5) {
float f6 = f2 - f;
float f7 = f4 - f3;
if (f6 < Math.min(f5 - f3, f4 - f5) * 2.0f) {
return f5 - ((f2 + f) / 2.0f);
}
if (f6 < f7) {
return f5 < (f3 + f4) / 2.0f ? f3 - f : f4 - f2;
}
if (f > f3) {
return f3 - f;
}
if (f2 < f4) {
return f4 - f2;
}
return 0.0f;
}
public float e() {
this.h.getValues(this.j);
return this.j[0];
}
public final boolean f(Matrix matrix, float f, float f2, int i) {
if (!l(i, 4)) {
return false;
}
matrix.getValues(this.j);
float f3 = this.j[0];
float min = Math.min(Math.max(1.0f, f3), 2.0f);
if (min == f3) {
return false;
}
float f4 = min / f3;
matrix.postScale(f4, f4, f, f2);
return true;
}
public final boolean g(Matrix matrix, int i) {
float f;
float f2;
if (!l(i, 3)) {
return false;
}
RectF rectF = this.k;
rectF.set(this.e);
matrix.mapRect(rectF);
if (l(i, 1)) {
float f3 = rectF.left;
float f4 = rectF.right;
RectF rectF2 = this.d;
f = d(f3, f4, rectF2.left, rectF2.right, this.e.centerX());
} else {
f = 0.0f;
}
if (l(i, 2)) {
float f5 = rectF.top;
float f6 = rectF.bottom;
RectF rectF3 = this.d;
f2 = d(f5, f6, rectF3.top, rectF3.bottom, this.e.centerY());
} else {
f2 = 0.0f;
}
if (f == 0.0f && f2 == 0.0f) {
return false;
}
matrix.postTranslate(f, f2);
return true;
}
/* JADX WARNING: Code restructure failed: missing block: B:10:0x0025, code lost:
if (r2 != 6) goto L_0x00ca;
*/
public boolean h(MotionEvent motionEvent) {
a.AbstractC0068a aVar;
b bVar;
b.a aVar2;
motionEvent.getAction();
int i = b.f.d.e.a.a;
int i2 = 0;
if (!this.c) {
return false;
}
b.f.l.a.a aVar3 = this.a.a;
Objects.requireNonNull(aVar3);
int actionMasked = motionEvent.getActionMasked();
if (!(actionMasked == 0 || actionMasked == 1)) {
if (actionMasked == 2) {
while (i2 < 2) {
int findPointerIndex = motionEvent.findPointerIndex(aVar3.c[i2]);
if (findPointerIndex != -1) {
aVar3.f[i2] = motionEvent.getX(findPointerIndex);
aVar3.g[i2] = motionEvent.getY(findPointerIndex);
}
i2++;
}
if (!aVar3.a && aVar3.f644b > 0) {
aVar3.b();
}
if (!(!aVar3.a || (aVar = aVar3.h) == null || (aVar2 = (bVar = (b) aVar).f645b) == null)) {
aVar2.b(bVar);
}
} else if (actionMasked == 3) {
aVar3.c();
aVar3.a();
} else if (actionMasked != 5) {
}
return true;
}
motionEvent.getPointerCount();
motionEvent.getActionMasked();
aVar3.c();
aVar3.f644b = 0;
while (i2 < 2) {
int pointerCount = motionEvent.getPointerCount();
int actionMasked2 = motionEvent.getActionMasked();
int i3 = ((actionMasked2 == 1 || actionMasked2 == 6) && i2 >= motionEvent.getActionIndex()) ? i2 + 1 : i2;
if (i3 >= pointerCount) {
i3 = -1;
}
if (i3 == -1) {
aVar3.c[i2] = -1;
} else {
aVar3.c[i2] = motionEvent.getPointerId(i3);
float[] fArr = aVar3.f;
float[] fArr2 = aVar3.d;
float x2 = motionEvent.getX(i3);
fArr2[i2] = x2;
fArr[i2] = x2;
float[] fArr3 = aVar3.g;
float[] fArr4 = aVar3.e;
float y2 = motionEvent.getY(i3);
fArr4[i2] = y2;
fArr3[i2] = y2;
aVar3.f644b++;
}
i2++;
}
if (aVar3.f644b > 0) {
aVar3.b();
}
return true;
}
public final void i() {
this.h.mapRect(this.f, this.e);
e.a aVar = this.f648b;
if (aVar != null && this.c) {
ZoomableDraweeView zoomableDraweeView = ZoomableDraweeView.this;
zoomableDraweeView.getLogTag();
zoomableDraweeView.hashCode();
int i = b.f.d.e.a.a;
if (zoomableDraweeView.n != null && ((c) zoomableDraweeView.o).e() > 1.1f) {
zoomableDraweeView.a(zoomableDraweeView.n, null);
}
zoomableDraweeView.invalidate();
}
}
public void j() {
b.f.d.e.a.i(c.class, ModelAuditLogEntry.CHANGE_KEY_PERMISSIONS_RESET);
this.a.a.a();
this.g.reset();
this.h.reset();
i();
}
public void k(boolean z2) {
this.c = z2;
if (!z2) {
j();
}
}
}