Created
December 23, 2019 13:07
-
-
Save Lavanyagaur22/c2f9e002e5177cd65b3467da460ef1a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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() { | |
FindAllTasksQuery.builder()?.build()?.let { | |
Utils.getApolloClient(this)?.query(it) | |
?.responseFetcher(ApolloResponseFetchers.NETWORK_FIRST) | |
?.enqueue(object : ApolloCall.Callback<FindAllTasksQuery.Data>() { | |
override fun onFailure(e: ApolloException) { | |
e.printStackTrace() | |
Log.e(TAG, "getTasks ----$e ") | |
} | |
override fun onResponse(response: Response<FindAllTasksQuery.Data>) { | |
//Change the UI accordingly | |
Log.e(TAG, "on Response getTasks : Data ${response.data()}") | |
val result = response.data()?.findAllTasks() | |
result?.forEach { allTasks -> | |
val title = allTasks.title() | |
val desc = allTasks.description() | |
val id = allTasks.id() | |
var firstName = "" | |
var lastName = "" | |
var email = "" | |
var userId = "" | |
allTasks.assignedTo()?.let { query -> | |
firstName = query.firstName() | |
lastName = query.lastName() | |
email = query.email() | |
userId = query.id() | |
} ?: kotlin.run { | |
firstName = "" | |
lastName = "" | |
email = "" | |
userId = "" | |
} | |
val taskOutput = UserOutput( | |
title, | |
desc, | |
id.toInt(), | |
firstName, | |
lastName, | |
userId, | |
) | |
runOnUiThread { | |
tasksList.add(taskOutput) | |
taskAdapter.notifyDataSetChanged() | |
} | |
} | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment