Browse Source

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>
Marcel Hibbe 2 years ago
parent
commit
5ba6148273

+ 5 - 1
app/src/main/java/com/nextcloud/talk/adapters/messages/PreviewMessageViewHolder.kt

@@ -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
     }
     }
 }
 }