From 5b8256d65ecbb3bab9142fbe112b532b46951344 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 14 Jul 2020 14:37:38 -0500 Subject: [PATCH] Use non-blocking daos in iCalendar --- .../main/java/org/tasks/caldav/iCalendar.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/tasks/caldav/iCalendar.kt b/app/src/main/java/org/tasks/caldav/iCalendar.kt index 2b60618d5..8735b8ed7 100644 --- a/app/src/main/java/org/tasks/caldav/iCalendar.kt +++ b/app/src/main/java/org/tasks/caldav/iCalendar.kt @@ -3,7 +3,7 @@ package org.tasks.caldav import at.bitfire.ical4android.Task import at.bitfire.ical4android.Task.Companion.tasksFromReader import com.todoroo.andlib.utility.DateUtilities -import com.todoroo.astrid.dao.TaskDaoBlocking +import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.helper.UUIDHelper import com.todoroo.astrid.service.TaskCreator import net.fortuna.ical4j.model.Parameter @@ -27,15 +27,15 @@ import javax.inject.Inject @Suppress("ClassName") class iCalendar @Inject constructor( - private val tagDataDao: TagDataDaoBlocking, + private val tagDataDao: TagDataDao, private val preferences: Preferences, - private val locationDao: LocationDaoBlocking, + private val locationDao: LocationDao, private val workManager: WorkManager, private val geofenceApi: GeofenceApi, private val taskCreator: TaskCreator, - private val tagDao: TagDaoBlocking, - private val taskDao: TaskDaoBlocking, - private val caldavDao: CaldavDaoBlocking) { + private val tagDao: TagDao, + private val taskDao: TaskDao, + private val caldavDao: CaldavDao) { companion object { private const val APPLE_SORT_ORDER = "X-APPLE-SORT-ORDER" @@ -98,7 +98,7 @@ class iCalendar @Inject constructor( } } - fun setPlace(taskId: Long, geo: Geo) { + suspend fun setPlace(taskId: Long, geo: Geo) { var place: Place? = locationDao.findPlace( geo.latitude.toLikeString(), geo.longitude.toLikeString()) @@ -121,7 +121,7 @@ class iCalendar @Inject constructor( geofenceApi.update(place) } - fun getTags(categories: List): List { + suspend fun getTags(categories: List): List { if (categories.isEmpty()) { return emptyList() } @@ -136,7 +136,7 @@ class iCalendar @Inject constructor( return tags } - fun toVtodo(caldavTask: CaldavTask, task: com.todoroo.astrid.data.Task): ByteArray { + suspend fun toVtodo(caldavTask: CaldavTask, task: com.todoroo.astrid.data.Task): ByteArray { val remoteModel = CaldavConverter.toCaldav(caldavTask, task) remoteModel.order = caldavTask.order val categories = remoteModel.categories @@ -160,7 +160,7 @@ class iCalendar @Inject constructor( return os.toByteArray() } - fun fromVtodo( + suspend fun fromVtodo( calendar: CaldavCalendar, existing: CaldavTask?, remote: Task, @@ -174,7 +174,7 @@ class iCalendar @Inject constructor( taskDao.createNew(task) caldavTask = CaldavTask(task.id, calendar.uuid, remote.uid, obj) } else { - task = taskDao.fetchBlocking(existing.task)!! + task = taskDao.fetch(existing.task)!! caldavTask = existing } CaldavConverter.apply(task, remote)