Clear avatar image before setting it in PersonaView & AvatarView. With this PeoplePickerView persona list has correct avatar

This commit is contained in:
mishramayank1 2023-01-04 22:32:07 +05:30 коммит произвёл mishramayank1
Родитель 75a2f92c4e
Коммит 5996312dbc
2 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -15,7 +15,6 @@ import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.appcompat.widget.AppCompatImageView
import android.util.AttributeSet
import android.util.Log
import com.microsoft.fluentui.theming.FluentUIContextThemeWrapper
enum class AvatarStyle {
@ -285,6 +284,14 @@ open class AvatarView : AppCompatImageView {
super.setImageDrawable(drawable)
}
fun clearAvatarImage(){
avatarImageBitmap = null
avatarImageDrawable = null
avatarImageResourceId = null
avatarImageUri = null
super.setImageDrawable(null)
}
override fun setImageBitmap(bitmap: Bitmap?) {
if (bitmap == null)
return
@ -337,6 +344,7 @@ open class AvatarView : AppCompatImageView {
}
fun AvatarView.setAvatar(avatar: IAvatar) {
clearAvatarImage()
name = avatar.name
email = avatar.email
avatarImageBitmap = avatar.avatarImageBitmap

Просмотреть файл

@ -125,6 +125,14 @@ class PersonaView : ListItemView {
private val avatarView = AvatarView(context)
fun clearAvatarImage(){
avatarImageBitmap = null
avatarImageDrawable = null
avatarImageResourceId = null
avatarImageUri = null
avatarView.clearAvatarImage()
}
@JvmOverloads
constructor(appContext: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(appContext, attrs, defStyleAttr) {
val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.PersonaView)
@ -185,6 +193,7 @@ class PersonaView : ListItemView {
}
fun PersonaView.setPersona(persona: IPersona) {
clearAvatarImage()
name = persona.name
email = persona.email
subtitle = persona.subtitle