From 99e7b9944c1db2073d6c5e239e8678158eef0860 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 20 Aug 2024 10:32:18 +0200 Subject: [PATCH] Remove global scope Signed-off-by: alperozturk --- .../java/com/nextcloud/receiver/NetworkChangeReceiver.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/receiver/NetworkChangeReceiver.kt b/app/src/main/java/com/nextcloud/receiver/NetworkChangeReceiver.kt index 51c5a1e3fd1f..380a2dbeb98c 100644 --- a/app/src/main/java/com/nextcloud/receiver/NetworkChangeReceiver.kt +++ b/app/src/main/java/com/nextcloud/receiver/NetworkChangeReceiver.kt @@ -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 { @@ -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) {