Created
April 6, 2019 08:29
-
-
Save Lavanyagaur22/fc4ad95560d4031441a56b75cfb92459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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