what-the-bank/sources/com/scb/phone/view/camera/CameraSourcePreview.java

116 lines
3.3 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.camera;
import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;
import com.google.android.gms.common.images.Size;
import com.kofax.mobile.sdk._internal.impl.camera.h;
import java.io.IOException;
/* loaded from: classes5.dex */
public class CameraSourcePreview extends ViewGroup {
public CameraSource a;
private boolean b;
private SurfaceView c;
public boolean d;
private int e;
public CameraSourcePreview(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.e = 1;
this.d = false;
this.b = false;
SurfaceView surfaceView = new SurfaceView(context);
this.c = surfaceView;
surfaceView.getHolder().addCallback(new LWm(this, (byte) 0));
addView(this.c);
}
public final void a() throws IOException, SecurityException {
if (this.d && this.b) {
this.a.aoc_(this.c.getHolder());
this.d = false;
}
}
/* loaded from: classes5.dex */
class LWm implements SurfaceHolder.Callback {
private CameraSourcePreview b;
@Override // android.view.SurfaceHolder.Callback
public final void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
}
private LWm(CameraSourcePreview cameraSourcePreview) {
this.b = cameraSourcePreview;
}
@Override // android.view.SurfaceHolder.Callback
public final void surfaceCreated(SurfaceHolder surfaceHolder) {
this.b.b = true;
try {
this.b.a();
} catch (IOException | SecurityException unused) {
}
}
@Override // android.view.SurfaceHolder.Callback
public final void surfaceDestroyed(SurfaceHolder surfaceHolder) {
this.b.b = false;
}
/* synthetic */ LWm(CameraSourcePreview cameraSourcePreview, byte b) {
this(cameraSourcePreview);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5;
int i6;
int i7;
int i8;
Size size;
CameraSource cameraSource = this.a;
if (cameraSource == null || (size = cameraSource.i) == null) {
i5 = 1024;
i6 = h.Ay;
} else {
i5 = size.getWidth();
i6 = size.getHeight();
}
if (this.e != 1) {
int i9 = i5;
i5 = i6;
i6 = i9;
}
int i10 = i3 - i;
int i11 = i4 - i2;
float f = i6;
float f2 = i10 / f;
float f3 = i5;
float f4 = i11 / f3;
if (f2 > f4) {
int i12 = (int) (f3 * f2);
int i13 = (i12 - i11) / 2;
i11 = i12;
i8 = i13;
i7 = 0;
} else {
int i14 = (int) (f * f4);
i7 = (i14 - i10) / 2;
i10 = i14;
i8 = 0;
}
for (int i15 = 0; i15 < getChildCount(); i15++) {
getChildAt(i15).layout(-i7, -i8, i10 - i7, i11 - i8);
}
try {
a();
} catch (IOException | SecurityException unused) {
}
}
}