diff --git a/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.kt index e1f73d2b5..1d6b3c935 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.kt @@ -29,11 +29,11 @@ open class CaldavTaskAdapter internal constructor(private val taskDao: TaskDao, val newParent = changeParent(task, indent, to) if (newParent != task.parent) { val newPosition = if (newTasksOnTop) { - caldavDao.findFirstTask(task.caldav, newParent) + caldavDao.findFirstTask(task.caldav!!, newParent) ?.takeIf { task.creationDate.toAppleEpoch() >= it} ?.minus(1) } else { - caldavDao.findLastTask(task.caldav, newParent) + caldavDao.findLastTask(task.caldav!!, newParent) ?.takeIf { task.creationDate.toAppleEpoch() <= it } ?.plus(1) } diff --git a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.kt index fe301e8a3..0b891c244 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.kt @@ -53,7 +53,7 @@ open class GoogleTaskAdapter internal constructor(private val taskDao: TaskDao, } taskDao.touch(task.id) if (BuildConfig.DEBUG) { - googleTaskDao.validateSorting(task.googleTaskList) + googleTaskDao.validateSorting(task.googleTaskList!!) } } } \ No newline at end of file diff --git a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt index 218d56f07..302518674 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt @@ -31,7 +31,7 @@ class GoogleTaskManualSortAdapter internal constructor(val taskDao: TaskDao, val } taskDao.touch(task.id) if (BuildConfig.DEBUG) { - googleTaskDao.validateSorting(task.googleTaskList) + googleTaskDao.validateSorting(task.googleTaskList!!) } } } \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/CaldavDao.kt b/app/src/main/java/org/tasks/data/CaldavDao.kt index ed9e6fbaa..c8ab853b4 100644 --- a/app/src/main/java/org/tasks/data/CaldavDao.kt +++ b/app/src/main/java/org/tasks/data/CaldavDao.kt @@ -198,9 +198,9 @@ abstract class CaldavDao { val previousPosition = task.caldavSortOrder if (newPosition != null) { if (newParent == previousParent && newPosition < previousPosition) { - shiftDown(task.caldav, newParent, newPosition, previousPosition) + shiftDown(task.caldav!!, newParent, newPosition, previousPosition) } else { - shiftDown(task.caldav, newParent, newPosition) + shiftDown(task.caldav!!, newParent, newPosition) } } caldavTask.cd_order = newPosition diff --git a/app/src/main/java/org/tasks/data/TaskContainer.java b/app/src/main/java/org/tasks/data/TaskContainer.java index ab8b2bc0e..194c34987 100644 --- a/app/src/main/java/org/tasks/data/TaskContainer.java +++ b/app/src/main/java/org/tasks/data/TaskContainer.java @@ -1,5 +1,6 @@ package org.tasks.data; +import androidx.annotation.Nullable; import androidx.room.Embedded; import com.todoroo.astrid.data.Task; import java.util.Objects; @@ -21,12 +22,20 @@ public class TaskContainer { return tags; } - public String getGoogleTaskList() { - return googletask == null ? null : googletask.getListId(); + public @Nullable String getGoogleTaskList() { + return isGoogleTask() ? googletask.getListId() : null; } - public String getCaldav() { - return caldavTask == null ? null : caldavTask.getCd_calendar(); + public boolean isGoogleTask() { + return googletask != null; + } + + public @Nullable String getCaldav() { + return isCaldavTask() ? caldavTask.getCd_calendar() : null; + } + + public boolean isCaldavTask() { + return caldavTask != null; } public String getNotes() {