public void getListHotel(String uid){
FirebaseFirestore db = FirebaseFirestore.getInstance();
List<Hotel> list = new ArrayList<>();
List<String> listIDHotel = new ArrayList<>();
db.collection("users/" + uid + "/favorites").addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
if (error == null){
if (!value.isEmpty()){
for (QueryDocumentSnapshot doc : value) {
Log.d("favorite1", doc.getId());
listIDHotel.add(doc.getId());
}
}else{
}
Log.d("FAVVM1", String.valueOf(listIDHotel.size()));
}
}
});
if(listIDHotel.size() == 0){
Log.d("FAVVM", "empty");
return;
}
}
I have a function but when I run app, I watch Log "FAVMM1": 1 but Log "FAVMM": 0. I don't understand why size of list become 0