mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-06-05 21:59:19 +02:00
add a camera initialization to SOS too
This commit is contained in:
parent
1f1f55e8e7
commit
d59db59dd4
@ -59,16 +59,9 @@ class MyCameraImpl(val context: Context) {
|
|||||||
disableFlashlight()
|
disableFlashlight()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNougatPlus()) {
|
if (!tryInitCamera()) {
|
||||||
if (camera == null) {
|
|
||||||
initCamera()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (camera == null) {
|
|
||||||
context.toast(R.string.camera_error)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (isStroboscopeRunning) {
|
if (isStroboscopeRunning) {
|
||||||
stopStroboscope()
|
stopStroboscope()
|
||||||
@ -88,6 +81,10 @@ class MyCameraImpl(val context: Context) {
|
|||||||
stopStroboscope()
|
stopStroboscope()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tryInitCamera()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if (isFlashlightOn) {
|
if (isFlashlightOn) {
|
||||||
disableFlashlight()
|
disableFlashlight()
|
||||||
}
|
}
|
||||||
@ -101,6 +98,20 @@ class MyCameraImpl(val context: Context) {
|
|||||||
bus!!.post(Events.StopSOS())
|
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() {
|
fun handleCameraSetup() {
|
||||||
if (isMarshmallow) {
|
if (isMarshmallow) {
|
||||||
setupMarshmallowCamera()
|
setupMarshmallowCamera()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user