Fix toasting on wrong thread

This commit is contained in:
Mygod
2020-08-07 07:00:08 +08:00
parent 7b94be74a2
commit e7cf432348

View File

@@ -118,7 +118,10 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
override fun onTetheringStarted() = updateTile()
override fun onTetheringFailed(error: Int?) {
Timber.d("onTetheringFailed: $error")
error?.let { Toast.makeText(this, TetheringManager.tetherErrorLookup(it), Toast.LENGTH_LONG).show() }
if (error != null) GlobalScope.launch(Dispatchers.Main.immediate) {
Toast.makeText(this@TetheringTileService, TetheringManager.tetherErrorLookup(error),
Toast.LENGTH_LONG).show()
}
updateTile()
}
override fun onException(e: Exception) {