aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-30 12:47:29 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-30 12:47:29 +0200
commitddb6c87ebfb1ab94ce8849da27beab0b8429d276 (patch)
treefa8f6f34ea333b6ab0fbe0427b4b4086af6b1183 /ui/src/main/java
parentversion: bump (diff)
downloadwireguard-android-ddb6c87ebfb1ab94ce8849da27beab0b8429d276.tar.xz
wireguard-android-ddb6c87ebfb1ab94ce8849da27beab0b8429d276.zip
ui: account for binding disappearing on detail fragment
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt18
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 fe26e39..3ac2520 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