add a camera initialization to SOS too

This commit is contained in:
tibbi 2019-08-22 16:33:57 +02:00
parent 1f1f55e8e7
commit d59db59dd4

View File

@ -59,15 +59,8 @@ class MyCameraImpl(val context: Context) {
disableFlashlight()
}
if (!isNougatPlus()) {
if (camera == null) {
initCamera()
}
if (camera == null) {
context.toast(R.string.camera_error)
return false
}
if (!tryInitCamera()) {
return false
}
if (isStroboscopeRunning) {
@ -88,6 +81,10 @@ class MyCameraImpl(val context: Context) {
stopStroboscope()
}
if (!tryInitCamera()) {
return false
}
if (isFlashlightOn) {
disableFlashlight()
}
@ -101,6 +98,20 @@ class MyCameraImpl(val context: Context) {
bus!!.post(Events.StopSOS())
}
private fun tryInitCamera(): Boolean {
if (!isNougatPlus()) {
if (camera == null) {
initCamera()
}
if (camera == null) {
context.toast(R.string.camera_error)
return false
}
}
return true
}
fun handleCameraSetup() {
if (isMarshmallow) {
setupMarshmallowCamera()