Skip to content

Commit e28525f

Browse files
committed
adding some crashfixes
1 parent 128f01c commit e28525f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ android {
6262
}
6363

6464
dependencies {
65-
implementation 'com.github.SimpleMobileTools:Simple-Commons:af11ea2e30'
65+
implementation 'com.github.SimpleMobileTools:Simple-Commons:f538687d6e'
6666
implementation 'org.greenrobot:eventbus:3.3.1'
6767
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
6868
}

app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/LollipopCameraFlash.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ class LollipopCameraFlash : CameraFlash {
1010
private var params: Camera.Parameters? = null
1111

1212
override fun toggleFlashlight(enable: Boolean) {
13-
if (camera == null || params == null || camera!!.parameters == null) {
13+
try {
14+
if (camera == null || params == null || camera!!.parameters == null) {
15+
return
16+
}
17+
} catch (e: Exception) {
1418
return
1519
}
20+
1621
val flashMode = if (enable) Camera.Parameters.FLASH_MODE_ON else Camera.Parameters.FLASH_MODE_OFF
1722
params!!.flashMode = flashMode
1823
camera!!.parameters = params
@@ -31,7 +36,7 @@ class LollipopCameraFlash : CameraFlash {
3136
}
3237

3338
override fun release() {
34-
camera!!.release()
39+
camera?.release()
3540
camera = null
3641
}
3742
}

0 commit comments

Comments
 (0)