Skip to content

Instantly share code, notes, and snippets.

@Lavanyagaur22
Created April 6, 2019 08:29
Show Gist options
  • Save Lavanyagaur22/fc4ad95560d4031441a56b75cfb92459 to your computer and use it in GitHub Desktop.
Save Lavanyagaur22/fc4ad95560d4031441a56b75cfb92459 to your computer and use it in GitHub Desktop.
fun getTasks() {
Log.e(TAG, "inside getTasks")
val client = Utils.getApolloClient(this)?.query(
AllTasksQuery.builder().build()
)
client?.enqueue(object : ApolloCall.Callback<AllTasksQuery.Data>() {
override fun onFailure(e: ApolloException) {
e.printStackTrace()
Log.e(TAG, e.toString())
}
override fun onResponse(response: Response<AllTasksQuery.Data>) {
val result = response.data()?.allTasks()
//Log to check for for correct results
Log.e(TAG, "onResponse: ${result?.get(1)?.title()} ${result?.get(1)?.version()}")
result?.forEach {
val title = it.title()
val desc = it.description()
val id = it.id()
val version: Int? = it.version()
val task = Task(title, desc, id.toInt(), version!!)
noteslist.add(task)
}
runOnUiThread {
taskAdapter.notifyDataSetChanged()
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment