summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-20 18:05:43 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-20 18:05:43 +0200
commit655a8538578c7e7a0979ff64ee87433f920a699f (patch)
tree611bd556ef9daaac5e0c55ca02dc895f8ad26230
parent847da23300e9bd0b8786ddb27ffdd5681023bc8d (diff)
TunnelListFragment: do not assume binding always exists
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt8
1 files changed, 4 insertions, 4 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
index 11ebc4d6..eb3d6f78 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
@@ -224,8 +224,8 @@ class TunnelListFragment : BaseFragment() {
binding ?: return
lifecycleScope.launch {
val tunnels = Application.getTunnelManager().getTunnels()
- if (newTunnel != null) viewForTunnel(newTunnel, tunnels).setSingleSelected(true)
- if (oldTunnel != null) viewForTunnel(oldTunnel, tunnels).setSingleSelected(false)
+ if (newTunnel != null) viewForTunnel(newTunnel, tunnels)?.setSingleSelected(true)
+ if (oldTunnel != null) viewForTunnel(oldTunnel, tunnels)?.setSingleSelected(false)
}
}
@@ -296,8 +296,8 @@ class TunnelListFragment : BaseFragment() {
}
}
- private fun viewForTunnel(tunnel: ObservableTunnel, tunnels: List<*>): MultiselectableRelativeLayout {
- return binding!!.tunnelList.findViewHolderForAdapterPosition(tunnels.indexOf(tunnel))!!.itemView as MultiselectableRelativeLayout
+ private fun viewForTunnel(tunnel: ObservableTunnel, tunnels: List<*>): MultiselectableRelativeLayout? {
+ return binding?.tunnelList?.findViewHolderForAdapterPosition(tunnels.indexOf(tunnel))?.itemView as? MultiselectableRelativeLayout
}
private inner class ActionModeListener : ActionMode.Callback {