Fix a crash caused by race

This commit is contained in:
Mygod
2020-05-23 08:55:14 +08:00
parent 7374d89f0e
commit a55a2a8886
2 changed files with 11 additions and 5 deletions

View File

@@ -127,9 +127,10 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick
}
R.id.configuration_repeater -> {
lifecycleScope.launchWhenCreated {
WifiApDialogFragment().withArg(WifiApDialogFragment.Arg(withContext(Dispatchers.Default) {
adapter.repeaterManager.configuration
} ?: return@launchWhenCreated, p2pMode = true)).show(this@TetheringFragment, CONFIGURE_REPEATER)
adapter.repeaterManager.getConfiguration()?.let { config ->
WifiApDialogFragment().withArg(WifiApDialogFragment.Arg(config, p2pMode = true)).show(
this@TetheringFragment, CONFIGURE_REPEATER)
}
}
true
}