Fix time display in chat

This commit is contained in:
Phillip Thelen 2024-09-18 13:42:27 +02:00
parent 2ffd6a10b0
commit bda5edf105

View file

@ -14,6 +14,7 @@ import com.habitrpg.android.habitica.ui.adapter.BaseRecyclerViewAdapter
import com.habitrpg.android.habitica.ui.adapter.DiffCallback
import com.habitrpg.android.habitica.ui.viewHolders.ChatRecyclerMessageViewHolder
import com.habitrpg.common.habitica.helpers.LanguageHelper
import java.text.DateFormat
import java.text.SimpleDateFormat
class ChatDiffCallback(oldList: List<BaseMainObject>, newList: List<BaseMainObject>) :
@ -126,7 +127,7 @@ class ChatRecyclerViewAdapter(user: User?, private val isTavern: Boolean) :
}
class SystemChatMessageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val dateTime = java.text.SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM, LanguageHelper.systemLocale)
private val dateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, LanguageHelper.systemLocale)
val binding = SystemChatMessageBinding.bind(itemView)
var onShouldExpand: (() -> Unit)? = null
@ -144,7 +145,7 @@ class SystemChatMessageViewHolder(itemView: View) : RecyclerView.ViewHolder(item
binding.textView.text = chatMessage?.text?.removePrefix("`")?.removeSuffix("`")
binding.systemMessageTimestamp.text =
chatMessage?.timestamp?.let { java.util.Date(it) }
?.let { dateTime.format(it) }
?.let { dateFormatter.format(it) }
if (isExpanded) {
binding.systemMessageTimestamp.visibility = View.VISIBLE
} else {