Fixed random contact avatar sometimes showing in chat rooms list while scrolling instead of group chat avatar
This commit is contained in:
parent
1204275b9a
commit
6e5885dec9
2 changed files with 8 additions and 12 deletions
|
@ -339,20 +339,15 @@ private suspend fun loadContactPictureWithCoil(
|
||||||
color: Int = 0,
|
color: Int = 0,
|
||||||
textColor: Int = 0
|
textColor: Int = 0
|
||||||
) {
|
) {
|
||||||
if (contact != null) {
|
|
||||||
val context = imageView.context
|
val context = imageView.context
|
||||||
|
if (contact != null && !contact.showGroupChatAvatar) {
|
||||||
val displayName = contact.contact.value?.name ?: contact.displayName.value.orEmpty()
|
val displayName = contact.contact.value?.name ?: contact.displayName.value.orEmpty()
|
||||||
val source = contact.contact.value?.getPictureUri(useThumbnail)
|
val source = contact.contact.value?.getPictureUri(useThumbnail)
|
||||||
|
|
||||||
imageView.load(source) {
|
imageView.load(source) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
error(
|
error(
|
||||||
if (contact.showGroupChatAvatar) {
|
if (displayName.isEmpty() || AppUtils.getInitials(displayName) == "+") {
|
||||||
val bg = AppCompatResources.getDrawable(context, R.drawable.generated_avatar_bg)
|
|
||||||
imageView.background = bg
|
|
||||||
AppCompatResources.getDrawable(context, R.drawable.icon_multiple_contacts_avatar)
|
|
||||||
} else if (displayName.isEmpty() || AppUtils.getInitials(displayName) == "+") {
|
|
||||||
val bg = AppCompatResources.getDrawable(context, R.drawable.generated_avatar_bg)
|
|
||||||
imageView.background = bg
|
|
||||||
AppCompatResources.getDrawable(context, R.drawable.icon_single_contact_avatar)
|
AppCompatResources.getDrawable(context, R.drawable.icon_single_contact_avatar)
|
||||||
} else {
|
} else {
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
|
@ -377,9 +372,9 @@ private suspend fun loadContactPictureWithCoil(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else if (contact != null && contact.showGroupChatAvatar) {
|
||||||
|
imageView.load(AppCompatResources.getDrawable(context, R.drawable.icon_multiple_contacts_avatar))
|
||||||
} else {
|
} else {
|
||||||
val bg = AppCompatResources.getDrawable(imageView.context, R.drawable.generated_avatar_bg)
|
|
||||||
imageView.background = bg
|
|
||||||
imageView.load(R.drawable.icon_single_contact_avatar)
|
imageView.load(R.drawable.icon_single_contact_avatar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
android:layout_height="@dimen/contact_avatar_size"
|
android:layout_height="@dimen/contact_avatar_size"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:src="@drawable/voip_single_contact_avatar_alt"
|
android:background="@drawable/generated_avatar_bg"
|
||||||
|
android:src="@drawable/voip_single_contact_avatar"
|
||||||
app:layout_constraintBottom_toTopOf="@id/date"
|
app:layout_constraintBottom_toTopOf="@id/date"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|
Loading…
Reference in a new issue