Preparing chat UI models

To be able to add messages to the MessagesListAdapter of a MessageList, we must implement ChatKit's IMessage interface in an appropriate Model. We will implement this model here. Create a com.example.messenger.utils.message package and add the following Message class within it:

package com.example.messenger.utils.messageimport com.stfalcon.chatkit.commons.models.IMessageimport com.stfalcon.chatkit.commons.models.IUserimport java.util.*data class Message(private val authorId: Long, private val body: String,private val createdAt: Date) : IMessage {  override fun getId(): String {    return authorId.toString()  }  override fun getCreatedAt(): Date {    return createdAt  }  override fun getUser(): IUser {    return Author(authorId ...

Get Kotlin Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.