feat(dm): 메시지 시간을 표시한다
This commit is contained in:
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.DiffUtil
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
|
import kr.co.vividnext.sodalive.chat.talk.room.formatMessageTime
|
||||||
import kr.co.vividnext.sodalive.extensions.loadUrl
|
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||||
import kr.co.vividnext.sodalive.v2.main.chat.dm.model.DmChatMessageStatus
|
import kr.co.vividnext.sodalive.v2.main.chat.dm.model.DmChatMessageStatus
|
||||||
import kr.co.vividnext.sodalive.v2.main.chat.dm.model.DmChatMessageUiItem
|
import kr.co.vividnext.sodalive.v2.main.chat.dm.model.DmChatMessageUiItem
|
||||||
@@ -84,11 +85,13 @@ class DmChatMessageAdapter(
|
|||||||
) : RecyclerView.ViewHolder(itemView) {
|
) : RecyclerView.ViewHolder(itemView) {
|
||||||
private val tvMessage = itemView.findViewById<TextView>(R.id.tv_message)
|
private val tvMessage = itemView.findViewById<TextView>(R.id.tv_message)
|
||||||
private val tvStatus = itemView.findViewById<TextView>(R.id.tv_status)
|
private val tvStatus = itemView.findViewById<TextView>(R.id.tv_status)
|
||||||
|
private val tvTime = itemView.findViewById<TextView>(R.id.tv_time)
|
||||||
private val ivRetry = itemView.findViewById<ImageView>(R.id.iv_retry)
|
private val ivRetry = itemView.findViewById<ImageView>(R.id.iv_retry)
|
||||||
private val messageContainer = itemView.findViewById<View>(R.id.message_container)
|
private val messageContainer = itemView.findViewById<View>(R.id.message_container)
|
||||||
|
|
||||||
fun bind(item: DmChatMessageUiItem) {
|
fun bind(item: DmChatMessageUiItem) {
|
||||||
tvMessage.text = item.textMessage
|
tvMessage.text = item.textMessage
|
||||||
|
tvTime.text = formatMessageTime(item.createdAt)
|
||||||
tvMessage.maxWidth = (itemView.resources.displayMetrics.widthPixels * MESSAGE_MAX_WIDTH_RATIO).toInt()
|
tvMessage.maxWidth = (itemView.resources.displayMetrics.widthPixels * MESSAGE_MAX_WIDTH_RATIO).toInt()
|
||||||
|
|
||||||
val statusText = when (item.status) {
|
val statusText = when (item.status) {
|
||||||
@@ -119,10 +122,12 @@ class DmChatMessageAdapter(
|
|||||||
private val ivProfile = itemView.findViewById<ImageView>(R.id.iv_profile)
|
private val ivProfile = itemView.findViewById<ImageView>(R.id.iv_profile)
|
||||||
private val tvName = itemView.findViewById<TextView>(R.id.tv_name)
|
private val tvName = itemView.findViewById<TextView>(R.id.tv_name)
|
||||||
private val tvMessage = itemView.findViewById<TextView>(R.id.tv_message)
|
private val tvMessage = itemView.findViewById<TextView>(R.id.tv_message)
|
||||||
|
private val tvTime = itemView.findViewById<TextView>(R.id.tv_time)
|
||||||
|
|
||||||
fun bind(item: DmChatMessageUiItem) {
|
fun bind(item: DmChatMessageUiItem) {
|
||||||
tvName.text = item.senderNickname
|
tvName.text = item.senderNickname
|
||||||
tvMessage.text = item.textMessage
|
tvMessage.text = item.textMessage
|
||||||
|
tvTime.text = formatMessageTime(item.createdAt)
|
||||||
tvMessage.maxWidth = (itemView.resources.displayMetrics.widthPixels * MESSAGE_MAX_WIDTH_RATIO).toInt()
|
tvMessage.maxWidth = (itemView.resources.displayMetrics.widthPixels * MESSAGE_MAX_WIDTH_RATIO).toInt()
|
||||||
ivProfile.loadUrl(item.senderProfileImageUrl) {
|
ivProfile.loadUrl(item.senderProfileImageUrl) {
|
||||||
placeholder(R.drawable.ic_placeholder_profile)
|
placeholder(R.drawable.ic_placeholder_profile)
|
||||||
|
|||||||
@@ -18,9 +18,25 @@
|
|||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:textColor="@color/color_777777"
|
android:textColor="@color/color_777777"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/tv_time"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tv_time"
|
||||||
|
tools:text="전송 중" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
android:fontFamily="@font/regular"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/gray_500"
|
||||||
|
android:textSize="12sp"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/message_container"
|
app:layout_constraintBottom_toBottomOf="@id/message_container"
|
||||||
app:layout_constraintEnd_toStartOf="@id/message_container"
|
app:layout_constraintEnd_toStartOf="@id/message_container"
|
||||||
tools:text="전송 중" />
|
app:layout_constraintHorizontal_bias="1"
|
||||||
|
app:layout_constraintHorizontal_chainStyle="packed"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
tools:text="오후 11:03" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/message_container"
|
android:id="@+id/message_container"
|
||||||
@@ -31,7 +47,7 @@
|
|||||||
android:paddingVertical="10dp"
|
android:paddingVertical="10dp"
|
||||||
app:layout_constrainedWidth="true"
|
app:layout_constrainedWidth="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/tv_status"
|
app:layout_constraintStart_toEndOf="@id/tv_time"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -73,4 +73,17 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:fontFamily="@font/regular"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/gray_500"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/message_group"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/message_group"
|
||||||
|
tools:text="오후 11:03" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user