Package-level declarations

Media comments.

Comments

Functional comments are provided by the MediaCommentator interface.

val photoManager: PhotoManager
val comments: MediaCommentator = photoManager.albums

Using this feature, you can leave comments on media files and view other users' comments.

Fetch Media Comments

First, you need to get comments on the media.

val commentator: MediaCommentator

lifecycleScope.launch(Dispatchers.IO) {
// Fetch comments from backend
commentator.fetchComments(mediaId = 0L)
}

lifecycleScope.launch(Dispatchers.IO) {
commentator.createCommentsFlow(
mediaId = 0L
).collect { comments -> // comments: List<CommentItem>
// Handle it...
}
}

Create Edit Delete Comment

When a comment is created, a task is created in the database, which is then executed by the worker.

val commentator: MediaCommentator

lifecycleScope.launch(Dispatchers.IO) {
commentator.createComment(mediaId = 0L, message = "My comment")
commentator.editComment(commentId = 0L, message = "My edited comment")
commentator.deleteComment(commentId = 0L)
}

Draft

The draft feature allows you to store unsent comment text in the database. The draft is unique for each media outlet.

val commentator: MediaCommentator

lifecycleScope.launch(Dispatchers.IO) {
var draft: String? = commentator.getDraft(mediaId = 0L)
commentator.saveDraft(mediaId = 0L, "Edited Draft")
commentator.deleteDraft(mediaId = 0L)
}

Types

Link copied to clipboard
data class CommentItem(val id: Long, val createdAt: Long, val updatedAt: Long, val authorId: Long, val authorName: String, val message: String, val state: CommentState) : Parcelable
Link copied to clipboard
Link copied to clipboard