While trying to retrieve data from Firestore observed that return value always comes as 0
. Can somebody please advise how this can be corrected?
public List<Passion> getPassionvalue() {
List<Passion> msglist = new ArrayList<>();
CollectionReference col_ref = this.get_collection_firestore("Passion")
col_ref
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful())
{
for(QueryDocumentSnapshot document : task.getResult())
{
Passion passion =document.toObject(Passion.class);
msglist.add(passion);
}
}
else {
}
}
});
return msglist; // return value is always 0 as if no data.
}
EDIT
Method in Repository Class:
public List<Passion> downloadpassion()
{
return fsDB.getPassionvalue();
}
Method in ViewModel Class:
public List<Passion> downloadpassionlist()
{
return mPassionRepository.downloadpassion();
}