Skip to content

Commit

Permalink
Prevent whistle quick action from crashing tools
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Mar 16, 2024
1 parent 349cecb commit 083e708
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.kylecorry.trail_sense.tools.whistle.quickactions
import android.annotation.SuppressLint
import android.view.MotionEvent
import android.widget.ImageButton
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import com.kylecorry.andromeda.core.coroutines.onDefault
import com.kylecorry.andromeda.core.coroutines.onMain
import com.kylecorry.andromeda.fragments.inBackground
import com.kylecorry.andromeda.sound.ISoundPlayer
import com.kylecorry.trail_sense.R
Expand All @@ -23,7 +25,15 @@ class QuickActionWhistle(btn: ImageButton, fragment: Fragment) :

fragment.inBackground {
onDefault {
whistle = Whistle()
try {
whistle = Whistle()
} catch (e: Exception) {
e.printStackTrace()
// The whistle couldn't be instantiated
onMain {
button.isVisible = false
}
}
}
}

Expand Down

0 comments on commit 083e708

Please sign in to comment.