Add nullable annotation to googletask/caldav lists

pull/996/head
Alex Baker 6 years ago
parent b9de4ea7ef
commit 2568383a71

@ -29,11 +29,11 @@ open class CaldavTaskAdapter internal constructor(private val taskDao: TaskDao,
val newParent = changeParent(task, indent, to) val newParent = changeParent(task, indent, to)
if (newParent != task.parent) { if (newParent != task.parent) {
val newPosition = if (newTasksOnTop) { val newPosition = if (newTasksOnTop) {
caldavDao.findFirstTask(task.caldav, newParent) caldavDao.findFirstTask(task.caldav!!, newParent)
?.takeIf { task.creationDate.toAppleEpoch() >= it} ?.takeIf { task.creationDate.toAppleEpoch() >= it}
?.minus(1) ?.minus(1)
} else { } else {
caldavDao.findLastTask(task.caldav, newParent) caldavDao.findLastTask(task.caldav!!, newParent)
?.takeIf { task.creationDate.toAppleEpoch() <= it } ?.takeIf { task.creationDate.toAppleEpoch() <= it }
?.plus(1) ?.plus(1)
} }

@ -53,7 +53,7 @@ open class GoogleTaskAdapter internal constructor(private val taskDao: TaskDao,
} }
taskDao.touch(task.id) taskDao.touch(task.id)
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
googleTaskDao.validateSorting(task.googleTaskList) googleTaskDao.validateSorting(task.googleTaskList!!)
} }
} }
} }

@ -31,7 +31,7 @@ class GoogleTaskManualSortAdapter internal constructor(val taskDao: TaskDao, val
} }
taskDao.touch(task.id) taskDao.touch(task.id)
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
googleTaskDao.validateSorting(task.googleTaskList) googleTaskDao.validateSorting(task.googleTaskList!!)
} }
} }
} }

@ -198,9 +198,9 @@ abstract class CaldavDao {
val previousPosition = task.caldavSortOrder val previousPosition = task.caldavSortOrder
if (newPosition != null) { if (newPosition != null) {
if (newParent == previousParent && newPosition < previousPosition) { if (newParent == previousParent && newPosition < previousPosition) {
shiftDown(task.caldav, newParent, newPosition, previousPosition) shiftDown(task.caldav!!, newParent, newPosition, previousPosition)
} else { } else {
shiftDown(task.caldav, newParent, newPosition) shiftDown(task.caldav!!, newParent, newPosition)
} }
} }
caldavTask.cd_order = newPosition caldavTask.cd_order = newPosition

@ -1,5 +1,6 @@
package org.tasks.data; package org.tasks.data;
import androidx.annotation.Nullable;
import androidx.room.Embedded; import androidx.room.Embedded;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import java.util.Objects; import java.util.Objects;
@ -21,12 +22,20 @@ public class TaskContainer {
return tags; return tags;
} }
public String getGoogleTaskList() { public @Nullable String getGoogleTaskList() {
return googletask == null ? null : googletask.getListId(); return isGoogleTask() ? googletask.getListId() : null;
} }
public String getCaldav() { public boolean isGoogleTask() {
return caldavTask == null ? null : caldavTask.getCd_calendar(); return googletask != null;
}
public @Nullable String getCaldav() {
return isCaldavTask() ? caldavTask.getCd_calendar() : null;
}
public boolean isCaldavTask() {
return caldavTask != null;
} }
public String getNotes() { public String getNotes() {

Loading…
Cancel
Save