From b58e4427ddaa5e20a2c232be1009960650935bc4 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Fri, 21 May 2021 13:24:49 +1000 Subject: [PATCH 1/3] fix profile picture not updated on home UI --- .../securesms/loki/views/ProfilePictureView.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 fbc469379e..4750a49f98 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) { @@ -146,13 +146,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) @@ -162,7 +162,7 @@ class ProfilePictureView : RelativeLayout { publicKey, displayName )).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().into(imageView) - imagesCached.add(publicKey) + profilePicturesCached[publicKey] = recipient.profileAvatar } } else { imageView.setImageDrawable(null) @@ -170,7 +170,7 @@ class ProfilePictureView : RelativeLayout { } fun recycle() { - imagesCached.clear() + profilePicturesCached.clear() } // endregion } \ No newline at end of file From 05535983e25a0c4ca2bf924db75697272794b5a0 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Fri, 21 May 2021 13:34:44 +1000 Subject: [PATCH 2/3] clean --- .../org/thoughtcrime/securesms/loki/views/ConversationView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt index e1a308b645..ab69f35034 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt @@ -90,4 +90,4 @@ class ConversationView : LinearLayout { return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!) } // endregion -} \ No newline at end of file +} From c90ab52cdf10382a01609d9f5ab15f57a5a5dc04 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Fri, 21 May 2021 13:36:21 +1000 Subject: [PATCH 3/3] clean --- .../org/thoughtcrime/securesms/loki/views/ConversationView.kt | 2 +- .../org/thoughtcrime/securesms/loki/views/ProfilePictureView.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt index ab69f35034..e1a308b645 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt @@ -90,4 +90,4 @@ class ConversationView : LinearLayout { return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!) } // endregion -} +} \ No newline at end of file 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 4750a49f98..217c113b03 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 @@ -173,4 +173,4 @@ class ProfilePictureView : RelativeLayout { profilePicturesCached.clear() } // endregion -} \ No newline at end of file +}