feat: message activities
This commit is contained in:
parent
eb2eae7d6c
commit
913d74b285
2 changed files with 17 additions and 4 deletions
|
@ -63,6 +63,10 @@ data class Activity(
|
||||||
val createdAt: Int,
|
val createdAt: Int,
|
||||||
@SerialName("user")
|
@SerialName("user")
|
||||||
val user: User?,
|
val user: User?,
|
||||||
|
@SerialName("recipient")
|
||||||
|
val recipient: User?,
|
||||||
|
@SerialName("messenger")
|
||||||
|
val messenger: User?,
|
||||||
@SerialName("media")
|
@SerialName("media")
|
||||||
val media: Media?,
|
val media: Media?,
|
||||||
@SerialName("replies")
|
@SerialName("replies")
|
||||||
|
|
|
@ -33,15 +33,15 @@ class ActivityItem(
|
||||||
override fun bind(viewBinding: ItemActivityBinding, position: Int) {
|
override fun bind(viewBinding: ItemActivityBinding, position: Int) {
|
||||||
binding = viewBinding
|
binding = viewBinding
|
||||||
|
|
||||||
binding.activityUserName.text = activity.user?.name
|
binding.activityUserName.text = activity.user?.name ?: activity.messenger?.name
|
||||||
binding.activityUserAvatar.loadImage(activity.user?.avatar?.medium)
|
binding.activityUserAvatar.loadImage(activity.user?.avatar?.medium ?: activity.messenger?.avatar?.medium)
|
||||||
binding.activityTime.text = ActivityItemBuilder.getDateTime(activity.createdAt)
|
binding.activityTime.text = ActivityItemBuilder.getDateTime(activity.createdAt)
|
||||||
val likeColor = ContextCompat.getColor(binding.root.context, R.color.yt_red)
|
val likeColor = ContextCompat.getColor(binding.root.context, R.color.yt_red)
|
||||||
val notLikeColor = ContextCompat.getColor(binding.root.context, R.color.bg_opp)
|
val notLikeColor = ContextCompat.getColor(binding.root.context, R.color.bg_opp)
|
||||||
binding.activityLike.setColorFilter(if (activity.isLiked == true) likeColor else notLikeColor)
|
binding.activityLike.setColorFilter(if (activity.isLiked == true) likeColor else notLikeColor)
|
||||||
binding.commentRepliesContainer.visibility =
|
binding.commentRepliesContainer.visibility =
|
||||||
if (activity.replyCount > 0) View.VISIBLE else View.GONE
|
if (activity.replyCount > 0) View.VISIBLE else View.GONE
|
||||||
binding.activityLikeCount.text = activity.likeCount.toString()
|
binding.activityLikeCount.text = (activity.likeCount?:0).toString()
|
||||||
|
|
||||||
binding.activityLike.setOnClickListener {
|
binding.activityLike.setOnClickListener {
|
||||||
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
|
@ -55,7 +55,7 @@ class ActivityItem(
|
||||||
} else {
|
} else {
|
||||||
activity.likeCount = activity.likeCount?.plus(1)
|
activity.likeCount = activity.likeCount?.plus(1)
|
||||||
}
|
}
|
||||||
binding.activityLikeCount.text = activity.likeCount.toString()
|
binding.activityLikeCount.text = (activity.likeCount?:0).toString()
|
||||||
activity.isLiked = !activity.isLiked!!
|
activity.isLiked = !activity.isLiked!!
|
||||||
binding.activityLike.setColorFilter(if (activity.isLiked == true) likeColor else notLikeColor)
|
binding.activityLike.setColorFilter(if (activity.isLiked == true) likeColor else notLikeColor)
|
||||||
|
|
||||||
|
@ -99,6 +99,15 @@ class ActivityItem(
|
||||||
markwon.setMarkdown(binding.activityContent, activity.text ?: "")
|
markwon.setMarkdown(binding.activityContent, activity.text ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"MessageActivity" -> {
|
||||||
|
binding.activityBannerContainer.visibility = View.GONE
|
||||||
|
binding.activityContent.visibility = View.VISIBLE
|
||||||
|
if (!(context as android.app.Activity).isDestroyed) {
|
||||||
|
val markwon = buildMarkwon(context, false)
|
||||||
|
markwon.setMarkdown(binding.activityContent, activity.message ?: "")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue