I have users object as below:
{
\"deviceTokens\" : {
\"SgJd7o1hK7YbJnygnYWvaz4qkr42\" : {
\"c-sfcTB3iEA:APA91bEvuzhX1nlrhoxVmR69lvwu0H1zyRjOXd5b1
Actually, I didn't wanted to create my own adapter, because I believed that FirebaseUI would not have such a limitation, but I was wrong. Anyways, this is how I approached:
First of all fetch all the data from the User Object from FirebaseDatabase and then, filter on our end and finally, set that data:
FirebaseDatabase.getInstance().getReference().child("users")
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable list = dataSnapshot.getChildren();
// Getting current user Id
String uid = getCurrentUserId();
// Filter User
List userList = new ArrayList<>();
for (DataSnapshot dataSnapshot1 : list) {
if (!dataSnapshot1.getKey().equals(uid)) {
userList.add(dataSnapshot1.getValue(User.class));
}
}
// Setting data
mBaseRecyclerAdapter.setItems(userList);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
I have created my own generic recycler adapter here: https://gist.github.com/chintansoni202/3c61aea787ae4bd49f26adee9dd40a08