Created
June 11, 2019 20:05
-
-
Save Lavanyagaur22/f7253efa81097750f7053cc018efc44e 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() { | |
noteslist.clear() | |
Log.e(TAG, "inside getTasks") | |
Log.e(TAG, " getActiveCallsCount : ${Utils.getApolloClient(this)?.activeCallsCount()}") | |
apolloStore = Utils.getApolloClient(this)?.apolloStore()!! | |
Log.e(TAG, " apolloStore : ${Utils.getApolloClient(this)?.apolloStore()}") | |
val client = Utils.getApolloClient(this)?.query( | |
AllTasksQuery.builder().build() | |
)?.watcher() | |
?.refetchCacheControl(CacheControl.CACHE_FIRST) | |
?.enqueueAndWatch(object : ApolloCall.Callback<AllTasksQuery.Data>() { | |
override fun onFailure(e: ApolloException) { | |
e.printStackTrace() | |
Log.e(TAG, "----$e ") | |
} | |
override fun onResponse(response: Response<AllTasksQuery.Data>) { | |
watchResponse.set(response) | |
Log.e(TAG, "on Response : Watcher ${response.data()}") | |
val result = response.data()?.allTasks() | |
Log.e( | |
TAG, | |
"onResponse-getTasks : ${result?.get(result.size - 1)?.title()} ${result?.get(result.size - 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 { | |
Log.e(TAG, " Size ${noteslist.size}") | |
taskAdapter.notifyDataSetChanged() | |
} | |
} | |
}) | |
Log.e(TAG, "watched operation ${client?.operation()}") | |
//client?.refetch() | |
// ?.httpCachePolicy(HttpCachePolicy.NETWORK_ONLY) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment