Clear avatar image before setting it in PersonaView & AvatarView. With this PeoplePickerView persona list has correct avatar
This commit is contained in:
Родитель
75a2f92c4e
Коммит
5996312dbc
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче