diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt index 69bed456ad..2226e9ef8b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt @@ -29,7 +29,7 @@ class ProfilePictureView : RelativeLayout { var additionalDisplayName: String? = null var isRSSFeed = false var isLarge = false - private val imagesCached = mutableSetOf() + private val profilePicturesCached = mutableMapOf() // region Lifecycle constructor(context: Context) : super(context) { @@ -142,13 +142,13 @@ class ProfilePictureView : RelativeLayout { private fun setProfilePictureIfNeeded(imageView: ImageView, publicKey: String, displayName: String?, @DimenRes sizeResId: Int) { if (publicKey.isNotEmpty()) { val recipient = Recipient.from(context, Address.fromSerialized(publicKey), false) - if (imagesCached.contains(publicKey)) return + if (profilePicturesCached.containsKey(publicKey) && profilePicturesCached[publicKey] == recipient.profileAvatar) return val signalProfilePicture = recipient.contactPhoto - if (signalProfilePicture != null && (signalProfilePicture as? ProfileContactPhoto)?.avatarObject != "0" - && (signalProfilePicture as? ProfileContactPhoto)?.avatarObject != "") { + val avatar = (signalProfilePicture as? ProfileContactPhoto)?.avatarObject + if (signalProfilePicture != null && avatar != "0" && avatar != "") { glide.clear(imageView) glide.load(signalProfilePicture).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).circleCrop().into(imageView) - imagesCached.add(publicKey) + profilePicturesCached[publicKey] = recipient.profileAvatar } else { val sizeInPX = resources.getDimensionPixelSize(sizeResId) glide.clear(imageView) @@ -158,7 +158,7 @@ class ProfilePictureView : RelativeLayout { publicKey, displayName )).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().into(imageView) - imagesCached.add(publicKey) + profilePicturesCached[publicKey] = recipient.profileAvatar } } else { imageView.setImageDrawable(null) @@ -166,7 +166,7 @@ class ProfilePictureView : RelativeLayout { } fun recycle() { - imagesCached.clear() + profilePicturesCached.clear() } // endregion -} \ No newline at end of file +}