【发布时间】:2021-06-21 03:35:41
【问题描述】:
我正在尝试显示各种用户(例如 tinder)的用户个人资料,但我想知道 firebase 是否总是向其他新用户显示最先注册的用户,或者迭代是随机的,这将保证结果是随机的每个人获得展示的机会都是平等的? 如果没有,有人知道如何在android中让它随机吗? 我是怎么做的
FirebaseDatabase.getInstance().getReference().child("Users").child(OppositeUserSex);
编辑 这是我认为排序无济于事的代码,因为我希望它是随机的
if(mAuth.getCurrentUser().isEmailVerified())
{
FirebaseDatabase.getInstance().getReference().child("Users").child(UserSex).child(currentUserID).child("isVerified").setValue(true);
}
DatabaseReference oppositeSexDB= FirebaseDatabase.getInstance().getReference().child("Users").child(OppositeUserSex);
System.out.println(OppositeUserSex + "oppositeUser");
oppositeSexDB.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull @NotNull DataSnapshot snapshot, @Nullable @org.jetbrains.annotations.Nullable String previousChildName) {
if(snapshot.exists())
{
if(!snapshot.child("Selection").child("Nah").hasChild(currentUserID)) {
if(snapshot.child("Url").exists() && snapshot.child("isVerified").exists()) { //If user has image only then show them else dont display them && if they are verified
items.add(new ItemModel(snapshot.child("Url").getValue().toString(), snapshot.child("Name").getValue().toString(), "", "", snapshot.getKey()));
}
adapter.notifyDataSetChanged();
}
}
}
【问题讨论】:
标签: android firebase firebase-realtime-database