summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-03-19 14:45:07 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-03-19 14:45:07 +0530
commit0899b49bb3d479747da960a8b2055374729eaa49 (patch)
treee28f11da71904a9adf44661d46133eaa96b6af27 /ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
parentfc0660ca8d5dd98b5a98a32e13896f9553a4311c (diff)
Use more Kotlin-esque code where applicable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt11
1 files changed, 4 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 22e5d94e..2ed1b1df 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
@@ -18,7 +18,6 @@ import com.wireguard.android.databinding.TunnelDetailPeerBinding
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.ui.EdgeToEdge.setUpRoot
import com.wireguard.android.ui.EdgeToEdge.setUpScrollingContent
-import com.wireguard.config.Config
import java.util.Timer
import java.util.TimerTask
@@ -27,7 +26,7 @@ import java.util.TimerTask
*/
class TunnelDetailFragment : BaseFragment() {
private var binding: TunnelDetailFragmentBinding? = null
- private var lastState: Tunnel.State? = Tunnel.State.TOGGLE
+ private var lastState = Tunnel.State.TOGGLE
private var timer: Timer? = null
private fun formatBytes(bytes: Long): String {
@@ -78,9 +77,9 @@ class TunnelDetailFragment : BaseFragment() {
}
override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) {
- if (binding == null) return
+ binding ?: return
binding!!.tunnel = newTunnel
- if (newTunnel == null) binding!!.config = null else newTunnel.configAsync.thenAccept { config: Config? -> binding!!.config = config }
+ if (newTunnel == null) binding!!.config = null else newTunnel.configAsync.thenAccept { config -> binding!!.config = config }
lastState = Tunnel.State.TOGGLE
updateStats()
}
@@ -94,9 +93,7 @@ class TunnelDetailFragment : BaseFragment() {
}
override fun onViewStateRestored(savedInstanceState: Bundle?) {
- if (binding == null) {
- return
- }
+ binding ?: return
binding!!.fragment = this
onSelectedTunnelChanged(null, selectedTunnel)
super.onViewStateRestored(savedInstanceState)