ui: account for binding disappearing on detail fragment
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
8a6f8f73cd
commit
ddb6c87ebf
@ -63,13 +63,17 @@ class TunnelDetailFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) {
|
override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) {
|
||||||
binding ?: return
|
val binding = binding ?: return
|
||||||
binding!!.tunnel = newTunnel
|
binding.tunnel = newTunnel
|
||||||
if (newTunnel == null) binding!!.config = null else lifecycleScope.launch {
|
if (newTunnel == null) {
|
||||||
|
binding.config = null
|
||||||
|
} else {
|
||||||
|
lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
binding!!.config = newTunnel.getConfigAsync()
|
binding.config = newTunnel.getConfigAsync()
|
||||||
} catch (_: Throwable) {
|
} catch (_: Throwable) {
|
||||||
binding!!.config = null
|
binding.config = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastState = Tunnel.State.TOGGLE
|
lastState = Tunnel.State.TOGGLE
|
||||||
|
Loading…
Reference in New Issue
Block a user