fix to show placeholder avatar when none is set by user

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-04-30 17:59:21 +02:00
parent 898728cef9
commit 050f0f4422
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
4 changed files with 12 additions and 5 deletions

View File

@ -184,7 +184,7 @@ class ConversationItem(
ConversationType.ROOM_GROUP_CALL,
ConversationType.FORMER_ONE_TO_ONE,
ConversationType.ROOM_PUBLIC_CALL ->
holder.binding.dialogAvatar.loadConversationAvatar(user, model)
holder.binding.dialogAvatar.loadConversationAvatar(user, model, false)
else -> holder.binding.dialogAvatar.visibility = View.GONE
}

View File

@ -807,7 +807,7 @@ class ConversationInfoActivity :
}
Conversation.ConversationType.ROOM_GROUP_CALL, Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!)
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!, true)
}
Conversation.ConversationType.ROOM_SYSTEM -> {

View File

@ -359,7 +359,7 @@ class ConversationInfoEditActivity :
}
Conversation.ConversationType.ROOM_GROUP_CALL, Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!)
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!, true)
}
Conversation.ConversationType.ROOM_SYSTEM -> {

View File

@ -54,9 +54,12 @@ private const val TAG = "ImageViewExtensions"
fun ImageView.loadConversationAvatar(
user: User,
conversation: Conversation
conversation: Conversation,
ignoreCache: Boolean
): io.reactivex.disposables
.Disposable {
var finalIgnoreCache = ignoreCache
val imageRequestUri = ApiUtils.getUrlForConversationAvatarWithVersion(
1,
user.baseUrl,
@ -64,6 +67,10 @@ fun ImageView.loadConversationAvatar(
conversation.avatarVersion
)
if (conversation.avatarVersion.isNullOrEmpty()) {
finalIgnoreCache = true
}
// these placeholders are only used when the request fails completely. The server also return default avatars
// when no own images are set. (although these default avatars can not be themed for the android app..)
val placeholder =
@ -77,7 +84,7 @@ fun ImageView.loadConversationAvatar(
else -> ContextCompat.getDrawable(context, R.drawable.account_circle_96dp)
}
return loadAvatarInternal(user, imageRequestUri, false, placeholder)
return loadAvatarInternal(user, imageRequestUri, finalIgnoreCache, placeholder)
}
fun ImageView.loadUserAvatar(