From 655a8538578c7e7a0979ff64ee87433f920a699f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 20 Sep 2020 18:05:43 +0200 Subject: [PATCH] TunnelListFragment: do not assume binding always exists Signed-off-by: Jason A. Donenfeld --- .../com/wireguard/android/fragment/TunnelListFragment.kt | 8 ++++---- 1 file 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 {