I'm fetching from the Firebase Cloud database all the users and I want to exclude one user (that current logged in users). The code:
Query usersQuery = fireDB.collection("users").orderBy("full_name", Query.Direction.ASCENDING);
final FirestoreRecyclerOptions<User> options = new FirestoreRecyclerOptions.Builder<User>().setQuery(usersQuery, User.class).build();
usersAdapter = new NewMessageUsersAdapter(options,getActivity());
usersRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
usersRecyclerView.setAdapter(usersAdapter);
usersAdapter.startListening();
I want to exclude connectedUserDocumentRef.getPath()
because he cannot write to himself. I know that firebase does not support negation queries (like doesNotContain
or !=
) so as I understand the change should be after building the query and fetching the data. I also could just ignore it in the onBindViewHolder
method of the adapter but then the number of items that are shown is not equal to the getCount
. How can I do it?