mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
use avatar version of conversations to avoid unnecessary reloading/flickering
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
0b5f38f232
commit
d560a4a2a9
@ -181,7 +181,7 @@ class ConversationItem(
|
||||
ConversationType.ROOM_GROUP_CALL,
|
||||
ConversationType.FORMER_ONE_TO_ONE,
|
||||
ConversationType.ROOM_PUBLIC_CALL ->
|
||||
holder.binding.dialogAvatar.loadConversationAvatar(user, model, isInitialLoad)
|
||||
holder.binding.dialogAvatar.loadConversationAvatar(user, model)
|
||||
|
||||
else -> holder.binding.dialogAvatar.visibility = View.GONE
|
||||
}
|
||||
|
@ -1000,10 +1000,11 @@ class ChatActivity :
|
||||
true
|
||||
)
|
||||
} else if (isGroupConversation() || isPublicConversation()) {
|
||||
url = ApiUtils.getUrlForConversationAvatar(
|
||||
url = ApiUtils.getUrlForConversationAvatarWithVersion(
|
||||
1,
|
||||
conversationUser!!.baseUrl,
|
||||
currentConversation!!.token
|
||||
currentConversation!!.token,
|
||||
currentConversation!!.avatarVersion
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ class ConversationInfoActivity :
|
||||
}
|
||||
|
||||
Conversation.ConversationType.ROOM_GROUP_CALL, Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
|
||||
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!, true)
|
||||
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!)
|
||||
}
|
||||
|
||||
Conversation.ConversationType.ROOM_SYSTEM -> {
|
||||
|
@ -359,7 +359,7 @@ class ConversationInfoEditActivity :
|
||||
}
|
||||
|
||||
Conversation.ConversationType.ROOM_GROUP_CALL, Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
|
||||
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!, true)
|
||||
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!)
|
||||
}
|
||||
|
||||
Conversation.ConversationType.ROOM_SYSTEM -> {
|
||||
|
@ -54,14 +54,14 @@ private const val TAG = "ImageViewExtensions"
|
||||
|
||||
fun ImageView.loadConversationAvatar(
|
||||
user: User,
|
||||
conversation: Conversation,
|
||||
replace: Boolean
|
||||
conversation: Conversation
|
||||
): io.reactivex.disposables
|
||||
.Disposable {
|
||||
val imageRequestUri = ApiUtils.getUrlForConversationAvatar(
|
||||
val imageRequestUri = ApiUtils.getUrlForConversationAvatarWithVersion(
|
||||
1,
|
||||
user.baseUrl,
|
||||
conversation.token
|
||||
conversation.token,
|
||||
conversation.avatarVersion
|
||||
)
|
||||
|
||||
// these placeholders are only used when the request fails completely. The server also return default avatars
|
||||
@ -77,7 +77,7 @@ fun ImageView.loadConversationAvatar(
|
||||
else -> ContextCompat.getDrawable(context, R.drawable.account_circle_96dp)
|
||||
}
|
||||
|
||||
return loadAvatarInternal(user, imageRequestUri, replace, placeholder)
|
||||
return loadAvatarInternal(user, imageRequestUri, false, placeholder)
|
||||
}
|
||||
|
||||
fun ImageView.loadUserAvatar(
|
||||
@ -100,17 +100,17 @@ fun ImageView.loadUserAvatar(
|
||||
private fun ImageView.loadAvatarInternal(
|
||||
user: User?,
|
||||
url: String,
|
||||
replace: Boolean,
|
||||
ignoreCache: Boolean,
|
||||
placeholder: Drawable?
|
||||
): io.reactivex.disposables
|
||||
.Disposable {
|
||||
val cachePolicy = if (replace) {
|
||||
val cachePolicy = if (ignoreCache) {
|
||||
CachePolicy.WRITE_ONLY
|
||||
} else {
|
||||
CachePolicy.ENABLED
|
||||
}
|
||||
|
||||
if (replace && this.result is SuccessResult) {
|
||||
if (ignoreCache && this.result is SuccessResult) {
|
||||
val result = this.result as SuccessResult
|
||||
val memoryCacheKey = result.memoryCacheKey
|
||||
val memoryCache = context.imageLoader.memoryCache
|
||||
|
@ -143,7 +143,10 @@ data class Conversation(
|
||||
var statusClearAt: Long? = 0,
|
||||
|
||||
@JsonField(name = ["callRecording"])
|
||||
var callRecording: Int = 0
|
||||
var callRecording: Int = 0,
|
||||
|
||||
@JsonField(name = ["avatarVersion"])
|
||||
var avatarVersion: String? = null
|
||||
|
||||
) : Parcelable {
|
||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||
|
@ -379,6 +379,11 @@ public class ApiUtils {
|
||||
return getUrlForRoom(version, baseUrl, token) + "/avatar";
|
||||
}
|
||||
|
||||
public static String getUrlForConversationAvatarWithVersion(int version, String baseUrl, String token,
|
||||
String avatarVersion) {
|
||||
return getUrlForRoom(version, baseUrl, token) + "/avatar?avatarVersion=" + avatarVersion;
|
||||
}
|
||||
|
||||
public static String getCredentials(String username, String token) {
|
||||
if (TextUtils.isEmpty(username) && TextUtils.isEmpty(token)) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user