From 49752d05505904157dd9f323772ab3b25c89af2c Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 8 Jul 2020 08:29:53 -0700 Subject: [PATCH] if device goes away at just the right time, user won't be able to set channel --- .../main/java/com/geeksville/mesh/MainActivity.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt index 2c7ad328c..a2d36be98 100644 --- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt +++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt @@ -333,7 +333,7 @@ class MainActivity : AppCompatActivity(), Logging, /// Ask user to rate in play store private fun askToRate() { exceptionReporter { // Got one IllegalArgumentException from inside this lib, but we don't want to crash our app because of bugs in this optional feature - + AppRate.with(this) .setInstallDays(10.toByte()) // default is 10, 0 means install day, 10 means app is launched 10 or more days later than installation .setLaunchTimes(10.toByte()) // default is 10, 3 means app is launched 3 or more times @@ -646,7 +646,16 @@ class MainActivity : AppCompatActivity(), Logging, } .setPositiveButton(R.string.accept) { _, _ -> debug("Setting channel from URL") - model.setChannel(channel.settings) + try { + model.setChannel(channel.settings) + } catch (ex: RemoteException) { + errormsg("Couldn't change channel ${ex.message}") + Toast.makeText( + this, + "Couldn't change channel, because radio is not yet connected. Please try again.", + Toast.LENGTH_SHORT + ).show() + } } .show() }