Created
September 26, 2021 17:00
-
-
Save a914-gowtham/bd0a3317f75f18b3b15b75274bc4d33a 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
private fun addGroupListener() { | |
val fireStore= FirebaseFirestore.getInstance() | |
val userCollection= fireStore.collection("Users") | |
val groupCollection= fireStore.collection("Groups") | |
userCollection.document(myUserId).addSnapshotListener { snapshot, error -> | |
if (error == null) { | |
val groups = snapshot?.get("groups") | |
val groupsIds = | |
if (groups == null) ArrayList() else groups as ArrayList<String> | |
for(id in groupsIds) | |
groupCollection.document(id) | |
.get().addOnSuccessListener { snapshot-> | |
val group=snapshot.toObject(Group::class.java) | |
groupDao.insertGroup(group) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment