I have the following code,
public CardsController(){
final Map<Integer, Card> temp = new HashMap<>();
for (int i=0; i<CardsInAlbum; i++){
temp.put(i, new Card(i));
}
String uID = FirebaseAuth.getInstance().getUid();
[1]FirebaseFirestore.getInstance()
.collection("albums").document(uID)
.collection("cards").get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
Card c = getCard(document.getData());
Log.d("CardsController", c.getNumber() + "" + " number:" + c.getNumber() + " state:" + c.getState());
[2] temp.put(c.getNumber(), c);
}
} else {
[3] Log.d(Tag, "Error getting documents: ", task.getException());
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
[4] Log.d(Tag, e.getMessage());
}
});
[5]Cards = temp;
}
I have set breakpoints in the lines [1] to [5], when debugging it first stops in [1] and then debugging line by line seems like it also reach the addOnCompleteListener and addOnFailureListener but it skips [2], [3] and [4]. I remember it was working (with no changes made to this code), so I don't know if there is some kind of cache from firebase as the offline database that prevents getting information from database, but I tried reseting the emulator and still does not work, any idea why could be happening with this?
PD: Checked logcat, there is none of the logged messages in the function.