I have a list of IDs of favorite items of a user locally stored in a list of strings. Now when user opens his favorite section the app needs to fetch all the items in the local favorite list from Cloud Firestore. Now what I see is only query that accepts a field and only a string (in my case only a single id of favorite item at a time).
Is there a way to pass the list of IDs as a Query in a single operation and get the result. What I am doing now is passing the IDs to RecylerView
adapter and fetching it one by one in the BindViewHolder
.
@Override
public void onBindViewHolder(final ImageViewHolder holder, int position) {
db.whereEqualTo("imageId",mUploads.get(position))
.get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
List<Upload> uploadsList = queryDocumentSnapshots.toObjects(Upload.class);
Upload uploadCurrent = uploadsList.get(0);
holder.materialCardView.setCardBackgroundColor(Color.parseColor(uploadCurrent.getImageColor()));
Glide.with(mContext)
.load(uploadCurrent.getImageUrl())
.transition(DrawableTransitionOptions.withCrossFade())
.centerCrop()
.into(holder.imageView);
}
});
}