jimu-decompiled/sources/com/bottle/hp/album/capture/preview/CapturePreview.java
2025-05-13 19:24:51 +02:00

92 lines
2.8 KiB
Java

package com.bottle.hp.album.capture.preview;
import android.util.Log;
import android.view.SurfaceHolder;
import com.bottle.hp.album.capture.camera.CameraWrapper;
import com.ubtrobot.log.ALog;
import java.io.IOException;
/* loaded from: classes.dex */
public class CapturePreview implements SurfaceHolder.Callback {
private final String a = CapturePreview.class.getSimpleName();
private boolean b = true;
private final CapturePreviewInterface c;
public final CameraWrapper d;
public CapturePreview(CapturePreviewInterface capturePreviewInterface, CameraWrapper cameraWrapper, SurfaceHolder surfaceHolder) {
this.c = capturePreviewInterface;
this.d = cameraWrapper;
a(surfaceHolder);
}
private void a(SurfaceHolder surfaceHolder) {
surfaceHolder.addCallback(this);
surfaceHolder.setType(3);
a(surfaceHolder, 0, 0);
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
a(surfaceHolder, i2, i3);
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceCreated(SurfaceHolder surfaceHolder) {
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
}
private void a(SurfaceHolder surfaceHolder, int i, int i2) {
if (this.b) {
try {
this.d.j();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
this.d.a(i, i2);
try {
this.d.a();
} catch (RuntimeException e2) {
e2.printStackTrace();
ALog.a(this.a).d("AutoFocus not available for preview");
}
try {
this.d.a(surfaceHolder);
a(true);
} catch (IOException e3) {
e3.printStackTrace();
ALog.a(this.a).d("Failed to show preview - unable to connect camera to preview (IOException)");
this.c.i();
} catch (RuntimeException e4) {
e4.printStackTrace();
ALog.a(this.a).d("Failed to show preview - unable to start camera preview (RuntimeException)");
this.c.i();
}
} catch (RuntimeException e5) {
e5.printStackTrace();
Log.e(this.a, "Failed to show preview - invalid parameters set to camera preview");
this.c.i();
}
}
public void a() {
if (this.b) {
try {
this.d.j();
a(false);
} catch (Exception e) {
e.printStackTrace();
Log.e(this.a, "Failed to clean up preview resources");
}
}
}
protected void a(boolean z) {
this.b = z;
}
}