Skip to content

Commit 083e708

Browse files
committed
Prevent whistle quick action from crashing tools
1 parent 349cecb commit 083e708

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/src/main/java/com/kylecorry/trail_sense/tools/whistle/quickactions/QuickActionWhistle.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package com.kylecorry.trail_sense.tools.whistle.quickactions
33
import android.annotation.SuppressLint
44
import android.view.MotionEvent
55
import android.widget.ImageButton
6+
import androidx.core.view.isVisible
67
import androidx.fragment.app.Fragment
78
import com.kylecorry.andromeda.core.coroutines.onDefault
9+
import com.kylecorry.andromeda.core.coroutines.onMain
810
import com.kylecorry.andromeda.fragments.inBackground
911
import com.kylecorry.andromeda.sound.ISoundPlayer
1012
import com.kylecorry.trail_sense.R
@@ -23,7 +25,15 @@ class QuickActionWhistle(btn: ImageButton, fragment: Fragment) :
2325

2426
fragment.inBackground {
2527
onDefault {
26-
whistle = Whistle()
28+
try {
29+
whistle = Whistle()
30+
} catch (e: Exception) {
31+
e.printStackTrace()
32+
// The whistle couldn't be instantiated
33+
onMain {
34+
button.isVisible = false
35+
}
36+
}
2737
}
2838
}
2939

0 commit comments

Comments
 (0)