I'm making a recyclerview. when using init block, I have problem. I expected code is executed in order. but It's out of order
Some code :
inner class TodoListFragmentRecyclerViewAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
val doListDTOs = ArrayList<DoListDTO>()
init {
Log.e("1","1")
doListListenerRegistration = fireStore.collection("doList").whereEqualTo("doListName",todoList_name).orderBy("doListTimestamp", Query.Direction.DESCENDING).limit(100)
.addSnapshotListener { querySnapshot, firebaseFirestoreException ->
if (querySnapshot == null) return@addSnapshotListener
doListDTOs.clear()
for (snapshot in querySnapshot.documents) {
val item = snapshot.toObject(DoListDTO::class.java)
doListDTOs.add(item!!)
Log.e("2",doListDTOs.toString())
notifyDataSetChanged()
}
}
Log.e("3",doListDTOs.toString())
}
}
I want log showed like below order
1 -> 2 -> 3
but, the actual output is
1 -> 3 -> 2
why is this?
As an additional issue, because of above order, last doListDTOs.toString() is null in log 3. but doListDTOs.toString in log 2 have some value. If It's not a order problem, I'd be grateful if you could tell me what the problem was.
>() { @Override public void onSuccess(List
– 서동빈 Oct 07 '19 at 08:35