From 8f9e8e2b22e843ccbc3e775f14aa6850c2671c56 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) {