Skip to content

Commit

Permalink
Remove global scope
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <alper_ozturk@proton.me>
  • Loading branch information
alperozturk96 committed Aug 20, 2024
1 parent 54c3d54 commit 8f9e8e2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.nextcloud.client.network.ConnectivityService
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

interface NetworkChangeListener {
Expand All @@ -25,9 +24,10 @@ class NetworkChangeReceiver(
private val connectivityService: ConnectivityService,
) : BroadcastReceiver() {

@OptIn(DelicateCoroutinesApi::class)
private val scope = CoroutineScope(Dispatchers.IO)

override fun onReceive(context: Context, intent: Intent?) {
GlobalScope.launch(Dispatchers.IO) {
scope.launch {
val isNetworkAndServerAvailable = connectivityService.isNetworkAndServerAvailable()

launch(Dispatchers.Main) {
Expand Down

0 comments on commit 8f9e8e2

Please sign in to comment.