diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-20 18:05:43 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-20 18:05:43 +0200 |
commit | 655a8538578c7e7a0979ff64ee87433f920a699f (patch) | |
tree | 611bd556ef9daaac5e0c55ca02dc895f8ad26230 /ui/src | |
parent | 847da23300e9bd0b8786ddb27ffdd5681023bc8d (diff) |
TunnelListFragment: do not assume binding always exists
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt | 8 |
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 { |