153 lines
4.6 KiB
Java
153 lines
4.6 KiB
Java
package io.beid.beidk.ui.camera;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.SurfaceHolder;
|
|
import android.view.SurfaceView;
|
|
import android.view.ViewGroup;
|
|
import java.io.IOException;
|
|
import o.C13120fRb;
|
|
import o.fQN;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public class CameraSourcePreview extends ViewGroup {
|
|
private boolean a;
|
|
private Context b;
|
|
private boolean c;
|
|
public C13120fRb d;
|
|
private SurfaceView e;
|
|
private GraphicOverlay i;
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void d() throws IOException, SecurityException {
|
|
if (this.c && this.a) {
|
|
this.e.getHolder().setFixedSize(getWidth(), getHeight());
|
|
this.d.aCy_(this.e.getHolder());
|
|
if (this.i != null) {
|
|
fQN fqn = this.d.f;
|
|
int min = Math.min(fqn.b, fqn.e);
|
|
int max = Math.max(fqn.b, fqn.e);
|
|
int i = this.b.getResources().getConfiguration().orientation;
|
|
if (i == 2 || i != 1) {
|
|
this.i.e(max, min, this.d.e);
|
|
} else {
|
|
this.i.e(min, max, this.d.e);
|
|
}
|
|
GraphicOverlay graphicOverlay = this.i;
|
|
synchronized (graphicOverlay.b) {
|
|
graphicOverlay.d.clear();
|
|
}
|
|
graphicOverlay.postInvalidate();
|
|
}
|
|
this.c = false;
|
|
}
|
|
}
|
|
|
|
public final void e(C13120fRb c13120fRb) throws IOException, SecurityException {
|
|
C13120fRb c13120fRb2;
|
|
if (c13120fRb == null && (c13120fRb2 = this.d) != null) {
|
|
c13120fRb2.a();
|
|
}
|
|
this.d = c13120fRb;
|
|
if (c13120fRb != null) {
|
|
this.c = true;
|
|
d();
|
|
}
|
|
}
|
|
|
|
@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;
|
|
fQN fqn;
|
|
C13120fRb c13120fRb = this.d;
|
|
if (c13120fRb == null || (fqn = c13120fRb.f) == null) {
|
|
i5 = i3;
|
|
i6 = i4;
|
|
} else {
|
|
i5 = fqn.b;
|
|
i6 = fqn.e;
|
|
}
|
|
int i9 = this.b.getResources().getConfiguration().orientation;
|
|
if (i9 == 2 || i9 != 1) {
|
|
int i10 = i5;
|
|
i5 = i6;
|
|
i6 = i10;
|
|
}
|
|
int i11 = i3 - i;
|
|
int i12 = i4 - i2;
|
|
float f = i6;
|
|
float f2 = i11 / f;
|
|
float f3 = i5;
|
|
float f4 = i12 / f3;
|
|
if (f2 > f4) {
|
|
int i13 = (int) (f3 * f2);
|
|
int i14 = (i13 - i12) / 2;
|
|
i12 = i13;
|
|
i8 = i14;
|
|
i7 = 0;
|
|
} else {
|
|
int i15 = (int) (f * f4);
|
|
i7 = (i15 - i11) / 2;
|
|
i11 = i15;
|
|
i8 = 0;
|
|
}
|
|
for (int i16 = 0; i16 < getChildCount(); i16++) {
|
|
getChildAt(i16).layout(-i7, -i8, i11 - i7, i12 - i8);
|
|
}
|
|
try {
|
|
d();
|
|
} catch (IOException | SecurityException unused) {
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes5.dex */
|
|
class IeS implements SurfaceHolder.Callback {
|
|
private CameraSourcePreview e;
|
|
|
|
@Override // android.view.SurfaceHolder.Callback
|
|
public final void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
|
|
}
|
|
|
|
@Override // android.view.SurfaceHolder.Callback
|
|
public final void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
|
this.e.a = false;
|
|
}
|
|
|
|
@Override // android.view.SurfaceHolder.Callback
|
|
public final void surfaceCreated(SurfaceHolder surfaceHolder) {
|
|
this.e.a = true;
|
|
try {
|
|
this.e.d();
|
|
} catch (IOException | SecurityException unused) {
|
|
}
|
|
}
|
|
|
|
/* synthetic */ IeS(CameraSourcePreview cameraSourcePreview, byte b) {
|
|
this(cameraSourcePreview);
|
|
}
|
|
|
|
private IeS(CameraSourcePreview cameraSourcePreview) {
|
|
this.e = cameraSourcePreview;
|
|
}
|
|
}
|
|
|
|
public final void e(C13120fRb c13120fRb, GraphicOverlay graphicOverlay) throws IOException, SecurityException {
|
|
this.i = graphicOverlay;
|
|
e(c13120fRb);
|
|
}
|
|
|
|
public CameraSourcePreview(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.b = context;
|
|
this.c = false;
|
|
this.a = false;
|
|
SurfaceView surfaceView = new SurfaceView(context);
|
|
this.e = surfaceView;
|
|
surfaceView.getHolder().addCallback(new IeS(this, (byte) 0));
|
|
addView(this.e);
|
|
}
|
|
}
|