@@ -33,8 +33,6 @@ class MyCameraImpl(val context: Context) {
3333 @Volatile
3434 private var isStroboscopeRunning = false
3535 @Volatile
36- private var shouldSOSStop = false
37- @Volatile
3836 private var isSOSRunning = false
3937
4038 fun newInstance (context : Context ) = MyCameraImpl (context)
@@ -95,17 +93,17 @@ class MyCameraImpl(val context: Context) {
9593 disableFlashlight()
9694 }
9795
98- if (isSOSRunning) {
96+ return if (isSOSRunning) {
9997 stopSOS()
98+ false
10099 } else {
101- isSOSRunning = true
102100 Thread (stroboscope).start()
101+ true
103102 }
104- return isSOSRunning
105103 }
106104
107105 fun stopSOS () {
108- shouldSOSStop = true
106+ shouldStroboscopeStop = true
109107 bus!! .post(Events .StopSOS ())
110108 }
111109
@@ -172,7 +170,6 @@ class MyCameraImpl(val context: Context) {
172170
173171 fun enableFlashlight () {
174172 shouldStroboscopeStop = true
175- shouldSOSStop = true
176173 if (isStroboscopeRunning || isSOSRunning) {
177174 shouldEnableFlashlight = true
178175 return
@@ -234,19 +231,17 @@ class MyCameraImpl(val context: Context) {
234231 bus?.unregister(this )
235232 isFlashlightOn = false
236233 shouldStroboscopeStop = true
237- shouldSOSStop = true
238234 }
239235
240236 private val stroboscope = Runnable {
241237 if (isStroboscopeRunning || isSOSRunning) {
242238 return @Runnable
243239 }
244240
241+ shouldStroboscopeStop = false
245242 if (isStroboSOS) {
246- shouldSOSStop = false
247243 isSOSRunning = true
248244 } else {
249- shouldStroboscopeStop = false
250245 isStroboscopeRunning = true
251246 }
252247
@@ -259,7 +254,6 @@ class MyCameraImpl(val context: Context) {
259254 Thread .sleep(stroboFrequency)
260255 } catch (e: Exception ) {
261256 shouldStroboscopeStop = true
262- shouldSOSStop = true
263257 }
264258 }
265259 } else {
@@ -302,11 +296,10 @@ class MyCameraImpl(val context: Context) {
302296 }
303297 }
304298
299+ shouldStroboscopeStop = false
305300 if (isStroboSOS) {
306- shouldSOSStop = false
307301 isSOSRunning = false
308302 } else {
309- shouldStroboscopeStop = false
310303 isStroboscopeRunning = false
311304 }
312305
0 commit comments