I have set two listeners
- Query to get the last message
- If the last message is group type I'm getting group info using group Listener
However, when I get the type from the message using messageListener and set groupListener it returns multiple onDataChange
Debug.e("parentsnap",dataSnapshot.getValue().toString()); gets called more than one times
How should I do it, please guide
groupListener = new ValueEventListener() {
@SuppressWarnings("unchecked")
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Debug.e("parent snap", dataSnapshot.getValue().toString());
for (DataSnapshot d :
dataSnapshot.getChildren()) {
//my code
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
groups.child(chatId).addValueEventListener(groupListener);