mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-14 18:21:57 +00:00
timestamp works slightly
This commit is contained in:
parent
de34a41ef4
commit
089d05050e
4 changed files with 33 additions and 23 deletions
|
|
@ -19,4 +19,15 @@
|
|||
android:textColor="@color/text_brand_neon"
|
||||
tools:text="System message"
|
||||
style="@style/Body1"/>
|
||||
<TextView
|
||||
android:id="@+id/system_message_timestamp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:singleLine="true"
|
||||
android:lines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Apr 20, 2:32 PM"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_quad"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.habitrpg.android.habitica.ui.adapter.social
|
||||
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
|
|
@ -14,6 +16,8 @@ import com.habitrpg.android.habitica.ui.viewHolders.ChatRecyclerMessageViewHolde
|
|||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||
import java.time.Instant
|
||||
import java.time.ZoneId
|
||||
|
||||
class ChatRecyclerViewAdapter(user: User?, private val isTavern: Boolean) : BaseRecyclerViewAdapter<ChatMessage, RecyclerView.ViewHolder>() {
|
||||
internal var user = user
|
||||
|
|
@ -45,7 +49,10 @@ class ChatRecyclerViewAdapter(user: User?, private val isTavern: Boolean) : Base
|
|||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (data[position].isSystemMessage) {
|
||||
(holder as? SystemChatMessageViewHolder)?.bind(data[position])
|
||||
val sysChatHolder = holder as? SystemChatMessageViewHolder ?: return
|
||||
sysChatHolder.bind(data[position],
|
||||
expandedMessageId == data[position].id)
|
||||
sysChatHolder.onShouldExpand = { expandMessage(data[position].id, position)}
|
||||
} else {
|
||||
val chatHolder = holder as? ChatRecyclerMessageViewHolder ?: return
|
||||
val message = data[position]
|
||||
|
|
@ -103,9 +110,22 @@ class ChatRecyclerViewAdapter(user: User?, private val isTavern: Boolean) : Base
|
|||
|
||||
class SystemChatMessageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
private val textView: TextView = itemView.findViewById(R.id.text_view)
|
||||
private val timestamp: TextView = itemView.findViewById(R.id.system_message_timestamp)
|
||||
private val dateTime = java.text.SimpleDateFormat("MMM dd, hh:mm aaa")
|
||||
|
||||
fun bind(chatMessage: ChatMessage?) {
|
||||
var onShouldExpand: (() -> Unit)? = null
|
||||
|
||||
init{
|
||||
textView.setOnClickListener {
|
||||
onShouldExpand?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(chatMessage: ChatMessage?, isExpanded: Boolean) {
|
||||
textView.text = chatMessage?.text?.removePrefix("`")?.removeSuffix("`")
|
||||
if(isExpanded) {
|
||||
timestamp.text = dateTime.format(chatMessage?.timestamp?.let { java.util.Date(it) })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# Habitica Server Port
|
||||
# local instance
|
||||
# PORT=3000
|
||||
PORT=80
|
||||
|
||||
# Genymotion
|
||||
# BASE_URL=http://10.0.3.2:3000
|
||||
|
||||
# Android Emulator
|
||||
# see: http://developer.android.com/tools/help/emulator.html#networkaddresses
|
||||
# BASE_URL=http://10.0.2.2:3000
|
||||
|
||||
# Production
|
||||
BASE_URL=https://habitica.com
|
||||
|
||||
STAGING_KEY=
|
||||
ANDROID_TESTING_UUID=
|
||||
APPLE_AUTH_CLIENT_ID=
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fabric_key=CHANGE_ME
|
||||
facebook_app_id=CHANGE_ME
|
||||
amplitude_app_id=CHANGE_ME
|
||||
Loading…
Reference in a new issue