diff --git a/app/src/main/java/com/github/libretube/api/obj/Comment.kt b/app/src/main/java/com/github/libretube/api/obj/Comment.kt index ef8f6f9c4..d21018e88 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Comment.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Comment.kt @@ -1,19 +1,19 @@ package com.github.libretube.api.obj -import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import kotlinx.serialization.Serializable -@JsonIgnoreProperties(ignoreUnknown = true) +@Serializable data class Comment( - val author: String? = null, - val commentId: String? = null, - val commentText: String? = null, - val commentedTime: String? = null, - val commentorUrl: String? = null, + val author: String, + val commentId: String, + val commentText: String, + val commentedTime: String, + val commentorUrl: String, val repliesPage: String? = null, - val hearted: Boolean? = null, - val likeCount: Long? = null, - val pinned: Boolean? = null, - val thumbnail: String? = null, - val verified: Boolean? = null, - val replyCount: Long? = null + val hearted: Boolean, + val likeCount: Long, + val pinned: Boolean, + val thumbnail: String, + val verified: Boolean, + val replyCount: Long ) diff --git a/app/src/main/java/com/github/libretube/api/obj/CommentsPage.kt b/app/src/main/java/com/github/libretube/api/obj/CommentsPage.kt index 88bb66a1b..3f8f83eec 100644 --- a/app/src/main/java/com/github/libretube/api/obj/CommentsPage.kt +++ b/app/src/main/java/com/github/libretube/api/obj/CommentsPage.kt @@ -1,10 +1,10 @@ package com.github.libretube.api.obj -import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import kotlinx.serialization.Serializable -@JsonIgnoreProperties(ignoreUnknown = true) +@Serializable data class CommentsPage( - var comments: MutableList = arrayListOf(), - val disabled: Boolean? = null, + var comments: List = emptyList(), + val disabled: Boolean = false, val nextpage: String? = null ) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 73502253b..ec33f5cf5 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -66,22 +66,21 @@ class CommentsAdapter( commentorImage.scaleY = REPLIES_ADAPTER_SCALE } - commentInfos.text = - comment.author.toString() + TextUtils.SEPARATOR + comment.commentedTime.toString() + commentInfos.text = comment.author + TextUtils.SEPARATOR + comment.commentedTime commentText.text = HtmlCompat.fromHtml( - comment.commentText.toString(), + comment.commentText, HtmlCompat.FROM_HTML_MODE_LEGACY ) ImageHelper.loadImage(comment.thumbnail, commentorImage) likesTextView.text = comment.likeCount.formatShort() - if (comment.verified == true) verifiedImageView.visibility = View.VISIBLE - if (comment.pinned == true) pinnedImageView.visibility = View.VISIBLE - if (comment.hearted == true) heartedImageView.visibility = View.VISIBLE + if (comment.verified) verifiedImageView.visibility = View.VISIBLE + if (comment.pinned) pinnedImageView.visibility = View.VISIBLE + if (comment.hearted) heartedImageView.visibility = View.VISIBLE if (comment.repliesPage != null) repliesAvailable.visibility = View.VISIBLE - if ((comment.replyCount ?: -1L) > 0L) { - repliesCount.text = comment.replyCount?.formatShort() + if (comment.replyCount > 0L) { + repliesCount.text = comment.replyCount.formatShort() } commentorImage.setOnClickListener { @@ -99,7 +98,7 @@ class CommentsAdapter( } root.setOnLongClickListener { - ClipboardHelper(root.context).save(comment.commentText.toString()) + ClipboardHelper(root.context).save(comment.commentText) Toast.makeText(root.context, R.string.copied, Toast.LENGTH_SHORT).show() true } diff --git a/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt b/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt index b8f4246b2..016b00ff0 100644 --- a/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt +++ b/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt @@ -48,7 +48,7 @@ class CommentsViewModel : ViewModel() { return@launch } val updatedPage = commentsPage.value?.apply { - comments = comments.plus(response.comments).toMutableList() + comments += response.comments } nextPage = response.nextpage commentsPage.postValue(updatedPage)