mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 20:29:02 +00:00
Fix chat message deserializing
This commit is contained in:
parent
e4b58d9cb7
commit
dd9d068daf
3 changed files with 12 additions and 9 deletions
|
|
@ -2,8 +2,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -158,9 +158,19 @@ class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUp
|
|||
if (messageWasSent()) {
|
||||
userLabel.tier = user?.contributor?.level ?: 0
|
||||
userLabel.username = name
|
||||
if (user?.username != null && releasedUsernames) {
|
||||
sublineTextView.text = "@${user?.username} ∙ ${msg.getAgoString(res)}"
|
||||
} else {
|
||||
sublineTextView.text = msg.getAgoString(res)
|
||||
}
|
||||
} else {
|
||||
userLabel.tier = msg.contributor?.level ?: 0
|
||||
userLabel.username = msg.user
|
||||
if (msg.username != null && releasedUsernames) {
|
||||
sublineTextView.text = "${msg.formattedUsername} ∙ ${msg.getAgoString(res)}"
|
||||
} else {
|
||||
sublineTextView.text = msg.getAgoString(res)
|
||||
}
|
||||
}
|
||||
when {
|
||||
userLabel.tier == 8 -> {
|
||||
|
|
@ -216,12 +226,6 @@ class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUp
|
|||
}
|
||||
messageWrapper.setScaledPadding(context, 8, 8, 8, 8)
|
||||
|
||||
if (msg.username != null && releasedUsernames) {
|
||||
sublineTextView.text = "${msg.formattedUsername} ∙ ${msg.getAgoString(res)}"
|
||||
} else {
|
||||
sublineTextView.text = msg.getAgoString(res)
|
||||
}
|
||||
|
||||
if (expandedMessageId == msg.id) {
|
||||
buttonsWrapper.visibility = View.VISIBLE
|
||||
deleteButton.visibility = if (shouldShowDelete()) View.VISIBLE else View.GONE
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class ChatMessageDeserializer : JsonDeserializer<ChatMessage> {
|
|||
message.user = obj.get("user").asString
|
||||
}
|
||||
|
||||
if (obj.has("username")) {
|
||||
if (obj.has("username") && obj.get("username").isJsonPrimitive) {
|
||||
message.username = obj.get("username").asString
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue