mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
catch snackbar exception
This commit is contained in:
parent
9cd1856bb9
commit
875c1542ea
2 changed files with 42 additions and 31 deletions
|
|
@ -737,24 +737,32 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}
|
||||
|
||||
private fun showSnackbar(msgId: Int) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
msgId,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
try {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
msgId,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
} catch (ex: IllegalStateException) {
|
||||
reportError("Snackbar couldn't find view for msgId $msgId")
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSnackbar(msg: String) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
msg,
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
|
||||
.setAction(R.string.okay) {
|
||||
// dismiss
|
||||
}
|
||||
.show()
|
||||
try {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
msg,
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
|
||||
.setAction(R.string.okay) {
|
||||
// dismiss
|
||||
}
|
||||
.show()
|
||||
} catch (ex: IllegalStateException) {
|
||||
reportError("Snackbar couldn't find view for msgString $msg")
|
||||
}
|
||||
}
|
||||
|
||||
fun perhapsChangeChannel(url: Uri? = requestedChannelUrl) {
|
||||
|
|
|
|||
|
|
@ -952,13 +952,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
|
||||
fun weNeedAccess(warningReason: String) {
|
||||
warn("Telling user we need need location access")
|
||||
|
||||
Snackbar.make(requireView(), warningReason, Snackbar.LENGTH_INDEFINITE)
|
||||
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
|
||||
.setAction(R.string.okay) {
|
||||
// dismiss
|
||||
}
|
||||
.show()
|
||||
showSnackbar(warningReason)
|
||||
}
|
||||
|
||||
locationSettingsResponse.addOnSuccessListener {
|
||||
|
|
@ -1001,6 +995,23 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
}
|
||||
}
|
||||
|
||||
private fun showSnackbar(msg: String) {
|
||||
try {
|
||||
Snackbar.make(
|
||||
requireView(),
|
||||
msg,
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
|
||||
.setAction(R.string.okay) {
|
||||
// dismiss
|
||||
}
|
||||
.show()
|
||||
} catch (ex: IllegalStateException) {
|
||||
reportError("Snackbar couldn't find view for msgString $msg")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
|
||||
|
|
@ -1022,15 +1033,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
if (!hasUSB) {
|
||||
// Warn user if BLE is disabled
|
||||
if (scanModel.bluetoothAdapter?.isEnabled != true) {
|
||||
Snackbar.make(
|
||||
requireView(),
|
||||
R.string.error_bluetooth,
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.setAction(R.string.okay) {
|
||||
// dismiss
|
||||
}
|
||||
.show()
|
||||
showSnackbar(getString(R.string.error_bluetooth))
|
||||
} else {
|
||||
if (binding.provideLocationCheckbox.isChecked)
|
||||
checkLocationEnabled(getString(R.string.location_disabled))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue