Use viewTreeLifecycleOwner

This commit is contained in:
Mygod
2020-06-01 16:21:49 -04:00
parent fb5283e61a
commit 379c3b226f
7 changed files with 12 additions and 11 deletions

View File

@@ -140,7 +140,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
private val tethering = BluetoothTethering(parent.requireContext()) { onTetheringStarted() }
init {
parent.lifecycle.addObserver(this)
parent.viewLifecycleOwner.lifecycle.addObserver(this)
}
override fun onDestroy(owner: LifecycleOwner) = tethering.close()

View File

@@ -161,7 +161,7 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick
true
}
R.id.configuration_repeater -> {
lifecycleScope.launchWhenCreated {
viewLifecycleOwner.lifecycleScope.launchWhenCreated {
adapter.repeaterManager.getConfiguration()?.let { config ->
WifiApDialogFragment().withArg(WifiApDialogFragment.Arg(config, p2pMode = true)).show(
this@TetheringFragment, CONFIGURE_REPEATER)