This commit is contained in:
2025-12-19 11:10:56 +08:00
parent ab3109f36a
commit af56fb4aeb
9 changed files with 71 additions and 57 deletions
@@ -11,16 +11,18 @@ class CameraUtils(private var activity: ComponentActivity) {
private var cameraController: LifecycleCameraController? = null
private var photoCaptureHelper: PhotoCaptureHelper? = null
private var failCallback: ((msg: String) -> Unit)? = null
// private var isCameraReady = false
fun takePhoto(callback: (Uri) -> Unit) {
fun takePhoto(succCallback: (Uri) -> Unit, failCallback: (msg: String) -> Unit = { }) {
this.failCallback = failCallback
cameraController?.let {
if (photoCaptureHelper == null) {
initCaptureHelper()
}
}
photoCaptureHelper?.let {
it.addSuccessCallback(callback)
it.addSuccessCallback(succCallback)
it.bindCameraCallback {
bind()
}
@@ -35,6 +37,7 @@ class CameraUtils(private var activity: ComponentActivity) {
onSuccess = {},
onError = { msg ->
//toast(msg)
failCallback?.invoke(msg)
}
)
}