Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.hyphenate.easeui.feature.conversation.config

import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import androidx.core.content.ContextCompat
import com.hyphenate.easeui.ChatUIKitClient
Expand All @@ -9,6 +11,7 @@ import com.hyphenate.easeui.configs.ChatUIKitAvatarConfig
import com.hyphenate.easeui.feature.conversation.interfaces.UnreadDotPosition
import com.hyphenate.easeui.feature.conversation.interfaces.UnreadStyle
import com.hyphenate.easeui.widget.ChatUIKitImageView
import androidx.core.graphics.drawable.toDrawable

/**
* Conversation item configuration
Expand Down Expand Up @@ -41,6 +44,7 @@ data class ChatUIKitConvItemConfig(
var avatarSize: Int = -1,
var avatarConfig: ChatUIKitAvatarConfig = ChatUIKitClient.getConfig()?.avatarConfig?.copy() ?: ChatUIKitAvatarConfig(),
var itemHeight: Float = -1f,
var itemBackground: Drawable? = null
) {
internal companion object {

Expand Down Expand Up @@ -119,6 +123,17 @@ data class ChatUIKitConvItemConfig(
a.getDimension(R.styleable.ChatUIKitConversationListLayout_ease_con_item_height, -1f).let {
if (it != -1f) itemConfig.itemHeight = it
}
a.getResourceId(R.styleable.ChatUIKitConversationListLayout_ease_con_item_background, -1).let { resId ->
if (resId != -1) {
itemConfig.itemBackground = ContextCompat.getDrawable(context, resId)
} else {
a.getColor(R.styleable.ChatUIKitConversationListLayout_ease_con_item_background, -1).let { color ->
if (color != -1) {
itemConfig.itemBackground = color.toDrawable()
}
}
}
}
a.recycle()
}
return itemConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import android.graphics.drawable.Drawable
import com.hyphenate.easeui.common.interfaces.IAvatarStyle

interface IConvItemStyle : IAvatarStyle, IConvItemTextStyle {
// fun setItemBackGround(backGround: Drawable?)

fun setItemBackGround(backGround: Drawable?)
fun setItemHeight(height: Int)

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.hyphenate.easeui.feature.conversation.viewholders

import android.R.attr.name
import android.R.id.message
import android.graphics.drawable.Drawable
import android.view.View
import androidx.viewbinding.ViewBinding
import coil.load
import com.hyphenate.easeui.ChatUIKitClient
import com.hyphenate.easeui.R
import com.hyphenate.easeui.base.ChatUIKitBaseRecyclerViewAdapter
import com.hyphenate.easeui.common.ChatLog
import com.hyphenate.easeui.common.ChatMessageDirection
import com.hyphenate.easeui.common.ChatMessageStatus
import com.hyphenate.easeui.common.ChatType
Expand Down Expand Up @@ -39,16 +42,10 @@ class ChatUIKitConversationViewHolder(
private var bgDrawable: Drawable? = null

init {
config?.bindView(viewBinding)
}

override fun initView(viewBinding: ViewBinding?) {
super.initView(viewBinding)
viewBinding?.let {
if (it is UikitItemConversationListBinding) {
ChatUIKitClient.getConfig()?.avatarConfig?.setAvatarStyle(it.avatar)
bgDrawable = it.root.background
}
viewBinding.let {
config?.bindView(it)
ChatUIKitClient.getConfig()?.avatarConfig?.setAvatarStyle(it.avatar)
bgDrawable = config?.itemBackground?:it.root.background
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ object ChatUIKitConversationViewHolderFactory {
inflater: LayoutInflater,
parent: ViewGroup?,
viewType: ChatUIKitConvViewType = ChatUIKitConvViewType.VIEW_TYPE_CONVERSATION,
style: ChatUIKitConvItemConfig = ChatUIKitConvItemConfig()
config: ChatUIKitConvItemConfig = ChatUIKitConvItemConfig()
): ChatUIKitBaseRecyclerViewAdapter.ViewHolder<ChatUIKitConversation> {
return when(viewType) {
ChatUIKitConvViewType.VIEW_TYPE_CONVERSATION -> {
ChatUIKitConversationViewHolder(
UikitItemConversationListBinding.inflate(inflater, parent, false),
style
config
)
}
else -> {
// Return default view holder
ChatUIKitConversationViewHolder(
UikitItemConversationListBinding.inflate(inflater, parent, false),
style
config
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ class ChatUIKitConversationListLayout @JvmOverloads constructor(
listAdapter?.setConversationItemConfig(itemConfig)
}

override fun setItemBackGround(backGround: Drawable?) {
itemConfig.itemBackground = backGround
notifyDataSetChanged()
}

override fun setItemHeight(height: Int) {
itemConfig.itemHeight = height.toFloat()
Expand Down