diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-15 23:30:20 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-15 23:46:11 +0200 |
commit | 49ac61304e5a244c674028d279f70f9631351f9c (patch) | |
tree | e196a0fb2cddb9674f6f72e50801a57e05599140 /ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt | |
parent | d79cdb0d41f05f53c13a0b247f54c28f42609e2f (diff) |
coroutines: use lifecycleScope where appropriate
There's still a bit of GlobalScope lingering around, which might be
removable.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
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.kt | 6 |
1 files changed, 3 insertions, 3 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 e81b4e6d..fa0dbf82 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt @@ -11,6 +11,7 @@ import android.view.MenuInflater import android.view.View import android.view.ViewGroup import androidx.databinding.DataBindingUtil +import androidx.lifecycle.lifecycleScope import com.wireguard.android.R import com.wireguard.android.backend.Tunnel import com.wireguard.android.databinding.TunnelDetailFragmentBinding @@ -19,7 +20,6 @@ import com.wireguard.android.model.ObservableTunnel import com.wireguard.android.widget.EdgeToEdge.setUpRoot import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import java.util.Timer import java.util.TimerTask @@ -82,7 +82,7 @@ class TunnelDetailFragment : BaseFragment() { override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) { binding ?: return binding!!.tunnel = newTunnel - if (newTunnel == null) binding!!.config = null else GlobalScope.launch(Dispatchers.Main.immediate) { + if (newTunnel == null) binding!!.config = null else lifecycleScope.launch(Dispatchers.Main.immediate) { try { binding!!.config = newTunnel.getConfigAsync() } catch (_: Throwable) { @@ -114,7 +114,7 @@ class TunnelDetailFragment : BaseFragment() { val state = tunnel.state if (state != Tunnel.State.UP && lastState == state) return lastState = state - GlobalScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch(Dispatchers.Main.immediate) { try { val statistics = tunnel.getStatisticsAsync() for (i in 0 until binding!!.peersLayout.childCount) { |