Created
August 16, 2016 10:39
-
-
Save harshadura/c6edaa94849dc5d0655ce76ecf6e885b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (final String groupId: memberList){ | |
Query searchQuery3 = database.child("userGroups").child(groupId); | |
ValueEventListener valueEventListener = new ValueEventListener() { | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
if (dataSnapshot.exists()) { | |
System.out.println("**i am here"); | |
final UserGroup userGroup = dataSnapshot.getValue(UserGroup.class); | |
final List<String> usersList = userGroup.getUsersList(); | |
for (int i=0; i<usersList.size(); i++) { | |
final String userId = usersList.get(i); | |
Query searchQuery2 = database.child("users").child(userId); | |
searchQuery2.addListenerForSingleValueEvent(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
if (dataSnapshot.exists()) { | |
System.out.println("user exists: " + dataSnapshot.getValue(User.class).toString()); | |
final User getUser = dataSnapshot.getValue(User.class); | |
HashMap<String, Boolean> newChatGroupList = getUser.chatGroupsHashMap; | |
newChatGroupList.put(newChatGroup.getId(), true); | |
getUser.chatGroupsHashMap = newChatGroupList; | |
database.child("users").child(userId).setValue(getUser); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
System.out.println(databaseError.getMessage()); | |
deferredResult.setResult("pages/chat_group_edit"); | |
} | |
}); | |
} | |
} | |
} | |
public void onCancelled(DatabaseError databaseError) { | |
System.out.println(databaseError.getMessage()); | |
} | |
}; | |
searchQuery3.addListenerForSingleValueEvent(valueEventListener); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment