mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
fix profile picture not updated on home UI
This commit is contained in:
parent
910787a960
commit
b58e4427dd
@ -29,7 +29,7 @@ class ProfilePictureView : RelativeLayout {
|
||||
var additionalDisplayName: String? = null
|
||||
var isRSSFeed = false
|
||||
var isLarge = false
|
||||
private val imagesCached = mutableSetOf<String>()
|
||||
private val profilePicturesCached = mutableMapOf<String,String?>()
|
||||
|
||||
// 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user