diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-30 12:47:29 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-30 12:47:29 +0200 |
commit | ddb6c87ebfb1ab94ce8849da27beab0b8429d276 (patch) | |
tree | fa8f6f34ea333b6ab0fbe0427b4b4086af6b1183 /ui/src/main/java/com/wireguard/android | |
parent | 8a6f8f73cd0d14bce021ddfd5fa7773b5a99c95c (diff) |
ui: account for binding disappearing on detail fragment
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt index fe26e394..3ac25201 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt @@ -63,13 +63,17 @@ class TunnelDetailFragment : BaseFragment() { } override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) { - binding ?: return - binding!!.tunnel = newTunnel - if (newTunnel == null) binding!!.config = null else lifecycleScope.launch { - try { - binding!!.config = newTunnel.getConfigAsync() - } catch (_: Throwable) { - binding!!.config = null + val binding = binding ?: return + binding.tunnel = newTunnel + if (newTunnel == null) { + binding.config = null + } else { + lifecycleScope.launch { + try { + binding.config = newTunnel.getConfigAsync() + } catch (_: Throwable) { + binding.config = null + } } } lastState = Tunnel.State.TOGGLE |