@@ -28,7 +28,6 @@ import com.owncloud.android.utils.BitmapUtils
2828import dagger.android.AndroidInjection
2929import kotlinx.coroutines.CoroutineScope
3030import kotlinx.coroutines.Dispatchers
31- import kotlinx.coroutines.SupervisorJob
3231import kotlinx.coroutines.launch
3332import kotlinx.coroutines.withContext
3433import javax.inject.Inject
@@ -43,22 +42,13 @@ class DashboardWidgetService : RemoteViewsService() {
4342 @Inject
4443 lateinit var widgetRepository: WidgetRepository
4544
46- private val serviceJob = SupervisorJob ()
47- private val serviceScope = CoroutineScope (Dispatchers .Main + serviceJob)
48-
4945 override fun onCreate () {
5046 super .onCreate()
5147 AndroidInjection .inject(this )
5248 }
5349
54- override fun onDestroy () {
55- super .onDestroy()
56- serviceJob.cancel()
57- }
58-
5950 override fun onGetViewFactory (intent : Intent ): RemoteViewsFactory {
6051 return StackRemoteViewsFactory (
61- serviceScope,
6252 this .applicationContext,
6353 userAccountManager,
6454 clientFactory,
@@ -68,9 +58,7 @@ class DashboardWidgetService : RemoteViewsService() {
6858 }
6959}
7060
71- @Suppress(" LongParameterList" )
7261class StackRemoteViewsFactory (
73- private val scope : CoroutineScope ,
7462 private val context : Context ,
7563 val userAccountManager : UserAccountManager ,
7664 val clientFactory : ClientFactory ,
@@ -97,7 +85,7 @@ class StackRemoteViewsFactory(
9785 }
9886
9987 override fun onDataSetChanged () {
100- scope .launch {
88+ CoroutineScope ( Dispatchers . IO ) .launch {
10189 try {
10290 if (! widgetConfiguration.user.isPresent) {
10391 Log_OC .w(TAG , " User not present for widget update" )
@@ -176,7 +164,7 @@ class StackRemoteViewsFactory(
176164 }
177165
178166 private fun loadIcon (widgetItem : DashboardWidgetItem , remoteViews : RemoteViews ) {
179- scope .launch {
167+ CoroutineScope ( Dispatchers . IO ) .launch {
180168 val client = OwnCloudClientManagerFactory .getDefaultSingleton()
181169 .getNextcloudClientFor(userAccountManager.user.toOwnCloudAccount(), context)
182170
0 commit comments