Extracted setupCameraView()
This commit is contained in:
parent
1ed96fce7d
commit
1228b6884d
|
@ -16,7 +16,6 @@ import com.google.zxing.common.HybridBinarizer
|
||||||
import com.google.zxing.qrcode.QRCodeReader
|
import com.google.zxing.qrcode.QRCodeReader
|
||||||
import net.codinux.banking.persistence.AndroidContext
|
import net.codinux.banking.persistence.AndroidContext
|
||||||
import net.codinux.banking.ui.MainActivity
|
import net.codinux.banking.ui.MainActivity
|
||||||
import net.codinux.banking.ui.config.DI
|
|
||||||
import net.codinux.log.logger
|
import net.codinux.log.logger
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
@ -41,12 +40,20 @@ actual object QrCodeService {
|
||||||
return // we don't have the permission to start the camera
|
return // we don't have the permission to start the camera
|
||||||
}
|
}
|
||||||
|
|
||||||
val cameraProviderFuture = ProcessCameraProvider.getInstance(mainActivity)
|
|
||||||
|
|
||||||
val previewView = remember {
|
val previewView = remember {
|
||||||
PreviewView(mainActivity)
|
PreviewView(mainActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupCameraView(previewView, mainActivity, resultCallback)
|
||||||
|
|
||||||
|
|
||||||
|
AndroidView(factory = { previewView }, modifier = Modifier.fillMaxSize())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun setupCameraView(previewView: PreviewView, mainActivity: MainActivity, resultCallback: (QrCodeReadResult) -> Unit) {
|
||||||
|
val cameraProviderFuture = ProcessCameraProvider.getInstance(mainActivity)
|
||||||
|
|
||||||
cameraProviderFuture.addListener({
|
cameraProviderFuture.addListener({
|
||||||
// Used to bind the lifecycle of cameras to the lifecycle owner
|
// Used to bind the lifecycle of cameras to the lifecycle owner
|
||||||
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
|
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
|
||||||
|
@ -79,9 +86,6 @@ actual object QrCodeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
}, ContextCompat.getMainExecutor(mainActivity))
|
}, ContextCompat.getMainExecutor(mainActivity))
|
||||||
|
|
||||||
|
|
||||||
AndroidView(factory = { previewView }, modifier = Modifier.fillMaxSize())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue