From ddb6c87ebfb1ab94ce8849da27beab0b8429d276 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 30 Sep 2020 12:47:29 +0200 Subject: ui: account for binding disappearing on detail fragment Signed-off-by: Jason A. Donenfeld --- .../wireguard/android/fragment/TunnelDetailFragment.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'ui/src/main/java/com/wireguard') 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 -- cgit v1.2.3