android - How to do ParseQuery for each item in a list of ParseObjects
问题描述
I want to do ParseAPI call in Kotlin where input is List<ParseObject>
and output is update MutableList<CustomObject>
where CustomObject
is data class containing ParseObject
and Int
. I can do something like this:
var newItems = mutableListOf<CustomObject>()
items.forEach{
//do query on relation column of item
//inside query.findInBackground -> (if error == null) add item to newItems
}
But I need to call callback function when new list is finished. I need something like await function for this call. Because i have to wait till callbacks for each item have ended and then return results to Activity.
That means function for query is defined like this:
fun getCurrentItems(c: Context, items: List<ParseObject>, callback:(MutableList<CustomObject>) -> Unit)
If all items were checked I just want to call:
callback(newItems)
解决方案
推荐阅读
- firebase - 如何在 python 中增加 Firestore 字段值?
- java - 从片段更改工具栏
- c++ - 如何使用 Gmock 连续调用每 n 次返回特定值
- node.js - 使用 Bittex API v3 的 INVALID_CONTENT_HASH 错误
- java - 是否可以将 spring-mvc 中的嵌套映射映射到全局路径?
- php - 将第二个数组推入第一个数组
- java - 是否可以从静态方法开始使用 Lombok @Builder?
- java - 分别处理 try-with-resources 块中 AutoCloseable 的 close-Method 抛出的 IOException
- google-cloud-firestore - 有没有办法只导出 Firestore 增量或自上次导出以来的更改(差异)?
- python-3.x - 从文件夹中读取所有图像并将其转换为单通道图像并保存