Почему после того, как я изменил аватар в FireUBaseUser's photoUrl и установил URL-адрес аватара для avatarUrl каждого Firestore'а uploadedImages, но все пост-реселлер реселлера не изменился на новый аватар из avatarUrl Firestore для uploadedImages?
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE_CHOOSE_AVATAR) {
if (resultCode == RESULT_OK) {
if (data != null) {
// val user = FirebaseAuth.getInstance().currentUser
val uri = data.data
val avatarRef = FirebaseStorage.getInstance().reference
.child("userAvatar")
.child(user!!.uid)
.child(uri.toString())
avatarRef.putFile(uri!!)
.continueWithTask {
if (!it.isSuccessful) {
it.exception?.let {
throw it
}
}
avatarRef.downloadUrl
}.addOnCompleteListener {
if (it.isSuccessful) {
val avatarDownloadUrl = it.result
val userProfileChangeRequest = UserProfileChangeRequest.Builder()
.setPhotoUri(avatarDownloadUrl)
.build()
user?.updateProfile(userProfileChangeRequest)
?.addOnCompleteListener { it1 ->
if (it1.isSuccessful) {
Picasso.get()
.load(user?.photoUrl)
.transform(CropCircleTransformation())
.into(avatar_url)
//TODO Change all post avatar
FirebaseFirestore.getInstance()
.collection("uploadedImages")
.whereEqualTo("uid", user?.uid)
.addSnapshotListener { querySnapshot, firebaseFirestoreException ->
if (querySnapshot != null && !querySnapshot.isEmpty) {
for (doc in querySnapshot.documents) {
Log.d(
TAG,
"uploadedImages's doc: ${doc.data}"
);
doc.data?.set(
"avatarUrl",
user?.photoUrl.toString()
)
}
} else {
firebaseFirestoreException.toString()
}
}