Fix null pointer when fetching positions

pull/1100/head
Alex Baker 4 years ago
parent 42c60006f3
commit 679e06982d

@ -94,7 +94,7 @@ class GtasksInvoker {
@Throws(IOException::class) @Throws(IOException::class)
suspend fun getAllPositions( suspend fun getAllPositions(
listId: String?, pageToken: String?): com.google.api.services.tasks.model.Tasks = listId: String?, pageToken: String?): com.google.api.services.tasks.model.Tasks? =
execute( execute(
service!! service!!
.tasks() .tasks()
@ -103,7 +103,7 @@ class GtasksInvoker {
.setShowDeleted(false) .setShowDeleted(false)
.setShowHidden(false) .setShowHidden(false)
.setPageToken(pageToken) .setPageToken(pageToken)
.setFields("items(id,parent,position),nextPageToken"))!! .setFields("items(id,parent,position),nextPageToken"))
@Throws(IOException::class) @Throws(IOException::class)
suspend fun createGtask( suspend fun createGtask(

@ -158,11 +158,10 @@ class GoogleTaskSynchronizer @Inject constructor(
var nextPageToken: String? = null var nextPageToken: String? = null
do { do {
val taskList = gtasksInvoker.getAllPositions(listId, nextPageToken) val taskList = gtasksInvoker.getAllPositions(listId, nextPageToken)
val items = taskList.items taskList?.items?.let {
if (items != null) { tasks.addAll(it)
tasks.addAll(items)
} }
nextPageToken = taskList.nextPageToken nextPageToken = taskList?.nextPageToken
} while (!isNullOrEmpty(nextPageToken)) } while (!isNullOrEmpty(nextPageToken))
return tasks return tasks
} }

Loading…
Cancel
Save