Skip to content

Instantly share code, notes, and snippets.

@metes
Created November 29, 2017 12:27
Show Gist options
  • Save metes/f9f6b849a35eee0d20776ce0361e5fa2 to your computer and use it in GitHub Desktop.
Save metes/f9f6b849a35eee0d20776ce0361e5fa2 to your computer and use it in GitHub Desktop.
private void addListenerForChatRoomStillExits() {
String currentUserId = SessionManager.getInstance().getString(Constant.FIREBASE_CURRENT_USER_ID);
userDatabase.child("users").child(currentUserId).child("conversations").orderByChild("isAccepted").equalTo(true).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
boolean isRoomExits = false;
if (dataSnapshot.exists()) {
for (DataSnapshot data : dataSnapshot.getChildren()) {
Object object = data.getValue();
HashMap lastMap = (HashMap) object;
if (lastMap.get("location").equals(location)) {
isRoomExits = true;
break;
}
//...
}
}
if (!isRoomExits) {
Toast.makeText(getBaseContext(), "room deleted", Toast.LENGTH_LONG).show();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment