From aa9e0e93b9bcc6e5e674d93638544cd87bc54c84 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 31 Jul 2020 12:06:31 -0500 Subject: [PATCH] Use Default dispatcher instead of IO --- app/src/main/java/org/tasks/Tasks.kt | 3 +-- app/src/main/java/org/tasks/dashclock/DashClockExtension.kt | 3 ++- app/src/main/java/org/tasks/injection/InjectingService.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/tasks/Tasks.kt b/app/src/main/java/org/tasks/Tasks.kt index ecf0f2f9b..38363328b 100644 --- a/app/src/main/java/org/tasks/Tasks.kt +++ b/app/src/main/java/org/tasks/Tasks.kt @@ -14,7 +14,6 @@ import dagger.hilt.android.HiltAndroidApp import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch import org.tasks.billing.BillingClient import org.tasks.billing.Inventory @@ -72,7 +71,7 @@ class Tasks : Application(), Configuration.Provider { } } - private fun backgroundWork() = CoroutineScope(Dispatchers.IO + SupervisorJob()).launch { + private fun backgroundWork() = CoroutineScope(Dispatchers.Default).launch { NotificationSchedulerIntentService.enqueueWork(context, false) CalendarNotificationIntentService.enqueueWork(context) refreshScheduler.get().scheduleAll() diff --git a/app/src/main/java/org/tasks/dashclock/DashClockExtension.kt b/app/src/main/java/org/tasks/dashclock/DashClockExtension.kt index ec898b053..9af36d734 100644 --- a/app/src/main/java/org/tasks/dashclock/DashClockExtension.kt +++ b/app/src/main/java/org/tasks/dashclock/DashClockExtension.kt @@ -22,7 +22,7 @@ import javax.inject.Inject @AndroidEntryPoint class DashClockExtension : DashClockExtension() { private val job = SupervisorJob() - private val scope = CoroutineScope(Dispatchers.IO + job) + private val scope = CoroutineScope(Dispatchers.Default + job) @Inject lateinit var defaultFilterProvider: DefaultFilterProvider @Inject lateinit var taskDao: TaskDao @@ -43,6 +43,7 @@ class DashClockExtension : DashClockExtension() { override fun onDestroy() { super.onDestroy() localBroadcastManager.unregisterReceiver(refreshReceiver) + job.cancel() } override fun onUpdateData(i: Int) { diff --git a/app/src/main/java/org/tasks/injection/InjectingService.kt b/app/src/main/java/org/tasks/injection/InjectingService.kt index 49db6151f..5a29b4024 100644 --- a/app/src/main/java/org/tasks/injection/InjectingService.kt +++ b/app/src/main/java/org/tasks/injection/InjectingService.kt @@ -15,7 +15,7 @@ import javax.inject.Inject abstract class InjectingService : Service() { private val job = SupervisorJob() - private val scope = CoroutineScope(Dispatchers.IO + job) + private val scope = CoroutineScope(Dispatchers.Default + job) @Inject lateinit var firebase: Firebase