From a2776b960ecbbe53e1717c1b7e1e84485f673842 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Wed, 8 Jul 2020 08:16:32 -0500 Subject: [PATCH] Make runBlocking crash when used on main thread --- .../BaseTaskEditViewModelTest.kt | 6 +++++ .../tasks/ui/editviewmodel/PriorityTests.kt | 7 ++---- .../tasks/ui/editviewmodel/ReminderTests.kt | 25 +++++++++---------- .../org/tasks/ui/editviewmodel/RepeatTests.kt | 7 ++---- .../ui/editviewmodel/TaskEditViewModelTest.kt | 7 ++---- .../org/tasks/ui/editviewmodel/TitleTests.kt | 5 +--- .../com/todoroo/astrid/alarms/AlarmService.kt | 2 +- .../com/todoroo/astrid/dao/TaskDaoBlocking.kt | 2 +- .../todoroo/astrid/service/TaskCompleter.kt | 2 +- .../com/todoroo/astrid/service/TaskMover.kt | 2 -- .../java/org/tasks/data/AlarmDaoBlocking.kt | 1 - .../java/org/tasks/data/CaldavDaoBlocking.kt | 1 - .../tasks/data/ContentProviderDaoBlocking.kt | 1 - .../org/tasks/data/DeletionDaoBlocking.kt | 1 - .../java/org/tasks/data/FilterDaoBlocking.kt | 1 - .../org/tasks/data/GoogleTaskDaoBlocking.kt | 1 - .../tasks/data/GoogleTaskListDaoBlocking.kt | 1 - .../org/tasks/data/LocationDaoBlocking.kt | 1 - .../main/java/org/tasks/data/RunBlocking.kt | 14 +++++++++++ .../java/org/tasks/data/TagDaoBlocking.kt | 1 - .../java/org/tasks/data/TagDataDaoBlocking.kt | 1 - .../tasks/data/TaskAttachmentDaoBlocking.kt | 1 - .../tasks/data/TaskListMetadataDaoBlocking.kt | 1 - .../org/tasks/data/UserActivityDaoBlocking.kt | 1 - .../main/java/org/tasks/jobs/CleanupWork.kt | 6 +---- .../java/org/tasks/jobs/WorkManagerImpl.kt | 2 +- .../notifications/NotificationDaoBlocking.kt | 2 +- .../preferences/DefaultFilterProvider.kt | 1 - .../java/org/tasks/ui/TaskEditViewModel.kt | 1 - 29 files changed, 45 insertions(+), 59 deletions(-) create mode 100644 app/src/main/java/org/tasks/data/RunBlocking.kt diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt index b77b02134..71a0aa3cf 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/BaseTaskEditViewModelTest.kt @@ -10,6 +10,8 @@ import com.todoroo.astrid.service.TaskDeleter import com.todoroo.astrid.service.TaskMover import com.todoroo.astrid.timers.TimerPlugin import dagger.hilt.android.qualifiers.ApplicationContext +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.runBlocking import org.junit.Before import org.tasks.calendars.CalendarEventProvider import org.tasks.injection.InjectingTestCase @@ -61,4 +63,8 @@ open class BaseTaskEditViewModelTest : InjectingTestCase() { db.alarmDao, alarmService) } + + protected fun save(): Boolean = runBlocking(Dispatchers.Main) { + viewModel.save() + } } \ No newline at end of file diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/PriorityTests.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/PriorityTests.kt index 7e9ea28a3..cbe86da55 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/PriorityTests.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/PriorityTests.kt @@ -1,11 +1,9 @@ package org.tasks.ui.editviewmodel -import androidx.test.annotation.UiThreadTest import com.natpryce.makeiteasy.MakeItEasy import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules -import kotlinx.coroutines.runBlocking import org.junit.Assert import org.junit.Test import org.tasks.injection.ProductionModule @@ -24,13 +22,12 @@ class PriorityTests : BaseTaskEditViewModelTest() { } @Test - @UiThreadTest - fun applyPriorityChange() = runBlocking { + fun applyPriorityChange() { val task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.HIGH)) viewModel.setup(task) viewModel.priority = Task.Priority.MEDIUM - viewModel.save() + save() Assert.assertEquals(Task.Priority.MEDIUM, task.priority) } diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/ReminderTests.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/ReminderTests.kt index 057d0e93c..1eb1a6b6b 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/ReminderTests.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/ReminderTests.kt @@ -1,6 +1,5 @@ package org.tasks.ui.editviewmodel -import androidx.test.annotation.UiThreadTest import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import kotlinx.coroutines.runBlocking @@ -14,76 +13,76 @@ import org.tasks.makers.TaskMaker.newTask @HiltAndroidTest class ReminderTests : BaseTaskEditViewModelTest() { @Test - @UiThreadTest fun whenDueReminder() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.whenDue = true - viewModel.save() + + save() assertTrue(taskDao.fetch(task.id)!!.isNotifyAtDeadline) } @Test - @UiThreadTest fun whenOverDueReminder() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.whenOverdue = true - viewModel.save() + + save() assertTrue(taskDao.fetch(task.id)!!.isNotifyAfterDeadline) } @Test - @UiThreadTest fun ringFiveTimes() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.ringFiveTimes = true - viewModel.save() + + save() assertTrue(taskDao.fetch(task.id)!!.isNotifyModeFive) } @Test - @UiThreadTest fun ringNonstop() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.ringNonstop = true - viewModel.save() + + save() assertTrue(taskDao.fetch(task.id)!!.isNotifyModeNonstop) } @Test - @UiThreadTest fun ringFiveTimesCantRingNonstop() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.ringNonstop = true viewModel.ringFiveTimes = true - viewModel.save() + + save() assertFalse(taskDao.fetch(task.id)!!.isNotifyModeNonstop) assertTrue(taskDao.fetch(task.id)!!.isNotifyModeFive) } @Test - @UiThreadTest fun ringNonStopCantRingFiveTimes() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.ringFiveTimes = true viewModel.ringNonstop = true - viewModel.save() + + save() assertFalse(taskDao.fetch(task.id)!!.isNotifyModeFive) assertTrue(taskDao.fetch(task.id)!!.isNotifyModeNonstop) diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/RepeatTests.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/RepeatTests.kt index 48fec28c7..66d6a3f8e 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/RepeatTests.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/RepeatTests.kt @@ -1,6 +1,5 @@ package org.tasks.ui.editviewmodel -import androidx.test.annotation.UiThreadTest import com.google.ical.values.RRule import com.natpryce.makeiteasy.MakeItEasy.with import dagger.hilt.android.testing.HiltAndroidTest @@ -16,14 +15,13 @@ import org.tasks.makers.TaskMaker.newTask @HiltAndroidTest class RepeatTests : BaseTaskEditViewModelTest() { @Test - @UiThreadTest fun changeRepeatAfterCompletion() = runBlocking { val task = newTask(with(TaskMaker.RRULE, RRule("RRULE:FREQ=DAILY;INTERVAL=1"))) viewModel.setup(task) viewModel.repeatAfterCompletion = true - viewModel.save() + save() assertEquals( "RRULE:FREQ=DAILY;INTERVAL=1;FROM=COMPLETION", @@ -31,7 +29,6 @@ class RepeatTests : BaseTaskEditViewModelTest() { } @Test - @UiThreadTest fun removeRepeatAfterCompletion() = runBlocking { val task = newTask() task.recurrence = "RRULE:FREQ=DAILY;INTERVAL=1;FROM=COMPLETION" @@ -39,7 +36,7 @@ class RepeatTests : BaseTaskEditViewModelTest() { viewModel.repeatAfterCompletion = false - viewModel.save() + save() assertEquals( "RRULE:FREQ=DAILY;INTERVAL=1", diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskEditViewModelTest.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskEditViewModelTest.kt index 6102802bf..3f6a3a37c 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskEditViewModelTest.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskEditViewModelTest.kt @@ -1,6 +1,5 @@ package org.tasks.ui.editviewmodel -import androidx.test.annotation.UiThreadTest import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -22,23 +21,21 @@ class TaskEditViewModelTest : BaseTaskEditViewModelTest() { } @Test - @UiThreadTest fun dontSaveTaskWithoutChanges() = runBlocking { viewModel.setup(newTask()) - assertFalse(viewModel.save()) + assertFalse(save()) assertTrue(taskDao.getAll().isEmpty()) } @Test - @UiThreadTest fun dontSaveTaskTwice() = runBlocking { viewModel.setup(newTask()) viewModel.priority = Task.Priority.HIGH - assertTrue(viewModel.save()) + assertTrue(save()) assertFalse(viewModel.save()) } diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/TitleTests.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/TitleTests.kt index 72a3293a8..25846147b 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/TitleTests.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/TitleTests.kt @@ -1,6 +1,5 @@ package org.tasks.ui.editviewmodel -import androidx.test.annotation.UiThreadTest import com.natpryce.makeiteasy.MakeItEasy.with import com.todoroo.astrid.data.Task.Priority.Companion.HIGH import dagger.hilt.android.testing.HiltAndroidTest @@ -26,20 +25,18 @@ class TitleTests : BaseTaskEditViewModelTest() { } @Test - @UiThreadTest fun saveWithEmptyTitle() = runBlocking { val task = newTask() viewModel.setup(task) viewModel.priority = HIGH - viewModel.save() + save() assertEquals("(No title)", taskDao.fetch(task.id)!!.title) } @Test - @UiThreadTest fun newTaskPrepopulatedWithTitleHasChanges() { viewModel.setup(newTask(with(TaskMaker.TITLE, "some title"))) diff --git a/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt b/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt index f45178ed7..37eded8b4 100644 --- a/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt +++ b/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt @@ -5,9 +5,9 @@ */ package com.todoroo.astrid.alarms -import kotlinx.coroutines.runBlocking import org.tasks.data.Alarm import org.tasks.data.AlarmDao +import org.tasks.data.runBlocking import org.tasks.jobs.AlarmEntry import org.tasks.jobs.NotificationQueue import java.util.* diff --git a/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt b/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt index a7fbdc912..0a9fd52aa 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt +++ b/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt @@ -9,9 +9,9 @@ import androidx.paging.DataSource import androidx.sqlite.db.SimpleSQLiteQuery import com.todoroo.astrid.api.Filter import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import org.tasks.data.SubtaskInfo import org.tasks.data.TaskContainer +import org.tasks.data.runBlocking import org.tasks.preferences.Preferences import javax.inject.Inject diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt b/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt index dce42a6de..da483d9f7 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt @@ -3,8 +3,8 @@ package com.todoroo.astrid.service import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import org.tasks.data.GoogleTaskDao +import org.tasks.data.runBlocking import timber.log.Timber import javax.inject.Inject diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt b/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt index 48a74b416..f317639cf 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt @@ -8,7 +8,6 @@ import com.todoroo.astrid.api.GtasksFilter import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.data.Task import dagger.hilt.android.qualifiers.ApplicationContext -import kotlinx.coroutines.runBlocking import org.tasks.BuildConfig import org.tasks.LocalBroadcastManager import org.tasks.data.* @@ -58,7 +57,6 @@ class TaskMover @Inject constructor( localBroadcastManager.broadcastRefresh() } - // TODO: remove runBlocking fun migrateLocalTasks() = runBlocking { val list = caldavDao.getLocalList(context) move(taskDao.getLocalTasks(), CaldavFilter(list)) diff --git a/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt b/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt index f3e242bad..5f5fe5028 100644 --- a/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt @@ -1,6 +1,5 @@ package org.tasks.data -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt b/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt index b114a42fa..9b8ef5a8d 100644 --- a/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt @@ -3,7 +3,6 @@ package org.tasks.data import android.content.Context import androidx.lifecycle.LiveData import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import org.tasks.filters.CaldavFilters import org.tasks.time.DateTimeUtils.currentTimeMillis import javax.inject.Inject diff --git a/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt b/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt index 0e6e6a28c..ac972817d 100644 --- a/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt @@ -3,7 +3,6 @@ package org.tasks.data import android.database.Cursor import androidx.sqlite.db.SupportSQLiteQuery import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt b/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt index 39963ca70..247a24e0f 100644 --- a/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt @@ -1,6 +1,5 @@ package org.tasks.data -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt b/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt index 192750de6..614b2fb70 100644 --- a/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt @@ -1,6 +1,5 @@ package org.tasks.data -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt b/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt index 5860b0df3..65f8b1b59 100644 --- a/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt @@ -1,7 +1,6 @@ package org.tasks.data import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import org.tasks.time.DateTimeUtils.currentTimeMillis import javax.inject.Inject diff --git a/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt b/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt index 850ab1684..b8b1d3690 100644 --- a/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt @@ -1,7 +1,6 @@ package org.tasks.data import androidx.lifecycle.LiveData -import kotlinx.coroutines.runBlocking import org.tasks.filters.GoogleTaskFilters import org.tasks.time.DateTimeUtils.currentTimeMillis import javax.inject.Inject diff --git a/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt b/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt index d895862fa..e1dc6723d 100644 --- a/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt @@ -1,7 +1,6 @@ package org.tasks.data import androidx.lifecycle.LiveData -import kotlinx.coroutines.runBlocking import org.tasks.filters.LocationFilters import org.tasks.time.DateTimeUtils.currentTimeMillis import javax.inject.Inject diff --git a/app/src/main/java/org/tasks/data/RunBlocking.kt b/app/src/main/java/org/tasks/data/RunBlocking.kt new file mode 100644 index 000000000..b66dc06d9 --- /dev/null +++ b/app/src/main/java/org/tasks/data/RunBlocking.kt @@ -0,0 +1,14 @@ +package org.tasks.data + +import com.todoroo.andlib.utility.AndroidUtilities.assertNotMainThread +import kotlinx.coroutines.CoroutineScope +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext + +@Throws(InterruptedException::class) +fun runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T { + assertNotMainThread() + + return kotlinx.coroutines.runBlocking(context, block) +} + diff --git a/app/src/main/java/org/tasks/data/TagDaoBlocking.kt b/app/src/main/java/org/tasks/data/TagDaoBlocking.kt index 502538df2..04c13fe97 100644 --- a/app/src/main/java/org/tasks/data/TagDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/TagDaoBlocking.kt @@ -1,7 +1,6 @@ package org.tasks.data import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt b/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt index ac694176e..f31c11cab 100644 --- a/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt @@ -3,7 +3,6 @@ package org.tasks.data import androidx.core.util.Pair import androidx.lifecycle.LiveData import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import org.tasks.filters.TagFilters import org.tasks.time.DateTimeUtils.currentTimeMillis import javax.inject.Inject diff --git a/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt b/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt index 2a49c801b..02a4e251d 100644 --- a/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt @@ -1,6 +1,5 @@ package org.tasks.data -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt b/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt index 8a97d2085..c8eda708e 100644 --- a/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt @@ -1,6 +1,5 @@ package org.tasks.data -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt b/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt index 68ce98d0e..535e937b7 100644 --- a/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt @@ -1,6 +1,5 @@ package org.tasks.data -import kotlinx.coroutines.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/jobs/CleanupWork.kt b/app/src/main/java/org/tasks/jobs/CleanupWork.kt index 67292d7fd..faae39c93 100644 --- a/app/src/main/java/org/tasks/jobs/CleanupWork.kt +++ b/app/src/main/java/org/tasks/jobs/CleanupWork.kt @@ -7,12 +7,8 @@ import androidx.work.WorkerParameters import com.todoroo.astrid.alarms.AlarmService import com.todoroo.astrid.reminders.ReminderService import com.todoroo.astrid.timers.TimerPlugin -import kotlinx.coroutines.runBlocking import org.tasks.analytics.Firebase -import org.tasks.data.DeletionDaoBlocking -import org.tasks.data.LocationDaoBlocking -import org.tasks.data.TaskAttachmentDaoBlocking -import org.tasks.data.UserActivityDaoBlocking +import org.tasks.data.* import org.tasks.files.FileHelper import org.tasks.injection.InjectingWorker import org.tasks.location.GeofenceApi diff --git a/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt b/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt index 41d3a199c..e402a7127 100644 --- a/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt +++ b/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt @@ -10,12 +10,12 @@ import androidx.work.* import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.data.Task -import kotlinx.coroutines.runBlocking import org.tasks.BuildConfig import org.tasks.R import org.tasks.data.CaldavDao import org.tasks.data.GoogleTaskListDao import org.tasks.data.Place +import org.tasks.data.runBlocking import org.tasks.date.DateTimeUtils.midnight import org.tasks.date.DateTimeUtils.newDateTime import org.tasks.jobs.WorkManager.Companion.MAX_CLEANUP_LENGTH diff --git a/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt b/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt index b7beaad42..bb700b823 100644 --- a/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt +++ b/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt @@ -1,6 +1,6 @@ package org.tasks.notifications -import kotlinx.coroutines.runBlocking +import org.tasks.data.runBlocking import javax.inject.Inject @Deprecated("use coroutines") diff --git a/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt b/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt index ebaf8e5b6..116e16fba 100644 --- a/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt +++ b/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt @@ -7,7 +7,6 @@ import com.todoroo.astrid.core.BuiltInFilterExposer import com.todoroo.astrid.core.BuiltInFilterExposer.getMyTasksFilter import com.todoroo.astrid.data.Task import dagger.hilt.android.qualifiers.ApplicationContext -import kotlinx.coroutines.runBlocking import org.tasks.R import org.tasks.Strings.isNullOrEmpty import org.tasks.data.* diff --git a/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt b/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt index 126378b62..1875b25a8 100644 --- a/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt +++ b/app/src/main/java/org/tasks/ui/TaskEditViewModel.kt @@ -30,7 +30,6 @@ import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toImmutableSet import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking import org.tasks.Event import org.tasks.R import org.tasks.Strings