This repository was archived by the owner on Jun 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathSystemMessageViewHolder.kt
More file actions
50 lines (41 loc) · 1.74 KB
/
SystemMessageViewHolder.kt
File metadata and controls
50 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package chat.rocket.android.chatroom.adapter
import android.graphics.Color
import android.text.method.LinkMovementMethod
import android.view.View
import androidx.core.view.isVisible
import chat.rocket.android.chatroom.uimodel.SystemMessageUiModel
import chat.rocket.android.emoji.EmojiReactionListener
import chat.rocket.core.model.MessageType
import kotlinx.android.synthetic.main.avatar.view.*
import kotlinx.android.synthetic.main.item_system_message.view.*
class SystemMessageViewHolder(
itemView: View,
reactionListener: EmojiReactionListener? = null,
private val avatarListener: (String) -> Unit,
private val joinVideoCallListener: (View) -> Unit
) : BaseViewHolder<SystemMessageUiModel>(itemView, null, reactionListener) {
init {
with(itemView) {
setupActionMenu(message_container)
text_content.movementMethod = LinkMovementMethod()
}
}
override fun bindViews(data: SystemMessageUiModel) {
with(itemView) {
day.text = data.currentDayMarkerText
day_marker_layout.isVisible = data.showDayMarker
new_messages_notif.isVisible = data.isFirstUnread
text_sender.text = data.senderName
text_content.text_content.text = data.content
button_join_video_call.isVisible = data.message.type is MessageType.JitsiCallStarted
button_join_video_call.setOnClickListener { joinVideoCallListener(it) }
image_avatar.setImageURI(data.avatar)
text_content.setTextColor(if (data.isTemporary) Color.GRAY else Color.BLACK)
setOnClickListener {
data.message.sender?.id?.let { userId ->
avatarListener(userId)
}
}
}
}
}