My app shows a Firebase db through a FirestoreRecyclerAdapter. I have put the code relating to the query in a separate method:
private void queryActive(){
queryActive = collectionRef
.whereEqualTo("activeStatus",1);
}
Each item in the recycler display has a switch through which the status of the underlying item's int field "activeStatus" can be toggled between "active" (1) and "inactive" (0).
The app shows indeed only the items that are "active". If I toggle the switch of a certain item to "inactive", that item indeed disappears. Excellent.
Now I want to order the active items according to their int field "categoryNumber". So I add an orderBy() method.
private void queryActive(){
queryActive = collectionRef
.whereEqualTo("activeStatus",1)
.orderBy("categoryNumber", Query.Direction.ASCENDING);
}
I understand that, as Firebase automatically adds a simple index for every field, there is no need to manually add an index. After all I'm not using composite indexes.
When I run the app, the active items are now ranked according to "categoryNumber", as intended. BUT the switch buttons of all items have become irresponsive. Checking in Firebase, the "1" indeed has nowhere been changed to "0", after trying to toggle the switches.
How is it possible that a switch button in the items' recycler cards becomes irresponsive after adding a simple index ordering expression to the query?