How to filter data on client side using firestore paging adapter?

Viewed 123

I am using FirestorePagingAdapter on a Recycler View(GridLayoutManager). The issue I am facing is i need to exclude some items based on certain condition that are not possible through queries. Previously i could use the above code inside onBindViewHolder to hide them (LinearLayoutManager) but that's not working with GridLayoutManager. So i need some solution to either hide these item from Recycler View(GridLayoutManager) without consuming space or some way by which i remove those item before they are used by the adapter.

if (/* some condition */) {
    RecyclerView.LayoutParams param = (RecyclerView.LayoutParams)
            holder.binding.getRoot().getLayoutParams();

    param.height = 0;

    param.width = LinearLayout.LayoutParams.MATCH_PARENT;
}

Is there any callback/procedure available in FirestorePagingAdapter in which i can filter the data before the adapter uses it?

Update:

I have a Dishes Collection. I have local ArrayList of Allergies that i want to check against dishAllergy Field. It should skip the documents that contains any of the element of my local ArrayList Also i have another filter already applied on dishCategory Field too in the query too.

firebaseFirestore.collection(DISHES_COLLECTION).whereArrayContains(DISH_CATEGORY, category);

Collection Document

0 Answers
Related