I\'m building an app for a friend and I use Firestore. What I want is to display a list of favorite places but for some reason, the list is always empty.
I
The reason for having a empty list got perfectly answered by Alex Mamo above.
I just like to present the same thing without needing to add an extra interface
.
In Kotlin you could just implement it like so:
fun readData(myCallback: (List) -> Unit) {
placesRef.get().addOnCompleteListener { task ->
if (task.isSuccessful) {
val list = ArrayList()
for (document in task.result) {
val name = document.data["name"].toString()
list.add(name)
}
myCallback(list)
}
}
}
and then use it like so:
readData() {
Log.d("TAG", it.size.toString())
})