BaseUiModel.kt 982 Bytes
Newer Older
1
package chat.rocket.android.chatroom.uimodel
2

3
import chat.rocket.core.model.Message
4 5
import java.security.InvalidParameterException

6
interface BaseUiModel<out T> {
7
    val message: Message
8 9 10 11
    val rawData: T
    val messageId: String
    val viewType: Int
    val layoutId: Int
12 13
    var reactions: List<ReactionUiModel>
    var nextDownStreamMessage: BaseUiModel<*>?
14
    var preview: Message?
15
    var isTemporary: Boolean
16
    var unread: Boolean?
17 18
    var currentDayMarkerText: String
    var showDayMarker: Boolean
19
    var menuItemsToHide: MutableList<Int>
20
    var permalink: String
21 22 23 24 25

    enum class ViewType(val viewType: Int) {
        MESSAGE(0),
        SYSTEM_MESSAGE(1),
        URL_PREVIEW(2),
Lucio Maciel's avatar
Lucio Maciel committed
26 27
        ATTACHMENT(3),
        MESSAGE_REPLY(4)
28 29 30
    }
}

31 32
internal fun Int.toViewType(): BaseUiModel.ViewType {
    return BaseUiModel.ViewType.values().firstOrNull { it.viewType == this }
Filipe de Lima Brito's avatar
Filipe de Lima Brito committed
33
        ?: throw InvalidParameterException("Invalid viewType: $this for BaseUiModel.ViewType")
34
}