fix to immediately view placeholder + set min height

without this fix, "getPayloadForImageLoader" was called before the placeholder was set (so it was null until getPayloadForImageLoader was called again after ~30seconds.). This is fixed by calling the super method at the end of "onBind".

min height was set to avoid very tiny previews (like for the placeholders)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-01-17 13:49:28 +01:00
parent 2ddb0782f3
commit 5ba6148273
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B

View file

@ -105,7 +105,8 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@Suppress("NestedBlockDepth", "ComplexMethod", "LongMethod") @Suppress("NestedBlockDepth", "ComplexMethod", "LongMethod")
override fun onBind(message: ChatMessage) { override fun onBind(message: ChatMessage) {
super.onBind(message) image.minimumHeight = DisplayUtils.convertDpToPixel(MIN_IMAGE_HEIGHT, context).toInt()
time.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp) time.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
if (userAvatar != null) { if (userAvatar != null) {
if (message.isGrouped || message.isOneToOneConversation) { if (message.isGrouped || message.isOneToOneConversation) {
@ -228,6 +229,8 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
true, true,
viewThemeUtils!! viewThemeUtils!!
) )
super.onBind(message)
} }
private fun longClickOnReaction(chatMessage: ChatMessage) { private fun longClickOnReaction(chatMessage: ChatMessage) {
@ -341,5 +344,6 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
const val ACTOR_TYPE_BOTS = "bots" const val ACTOR_TYPE_BOTS = "bots"
const val ACTOR_ID_CHANGELOG = "changelog" const val ACTOR_ID_CHANGELOG = "changelog"
const val KEY_NAME = "name" const val KEY_NAME = "name"
const val MIN_IMAGE_HEIGHT = 100F
} }
} }