package com.gh.gamecenter.forum.home.follow

import com.gh.gamecenter.entity.FollowUserEntity

abstract class AllFollowedItem() {

    abstract val itemType: Int

    open fun areItemsTheSame(other: AllFollowedItem): Boolean {
        return other.itemType == itemType && doAreItemsTheSame(other)
    }

    open fun areContentsTheSame(other: AllFollowedItem): Boolean {
        return other.itemType == itemType && doAreContentsTheSame(other)
    }

    open fun doAreItemsTheSame(other: AllFollowedItem): Boolean = true

    open fun doAreContentsTheSame(other: AllFollowedItem): Boolean = this == other

    companion object {

        const val ALL_FOLLOWED_ITEM_TYPE_NO_TOP = 0
        const val ALL_FOLLOWED_ITEM_TYPE_NORMAL = 1
        const val ALL_FOLLOWED_ITEM_TYPE_MY_FOLLOW_HEADER = 2
    }
}

class AllFollowedNoTopItem : AllFollowedItem() {
    override val itemType: Int
        get() = ALL_FOLLOWED_ITEM_TYPE_NO_TOP

}

data class AllFollowedMyFollowedHeaderItem(val isTop: Boolean) : AllFollowedItem() {
    override val itemType: Int
        get() = ALL_FOLLOWED_ITEM_TYPE_MY_FOLLOW_HEADER
}

data class AllFollowedNormalItem(
    val data: FollowUserEntity,
    var isTop: Boolean
) : AllFollowedItem() {
    override val itemType: Int
        get() = ALL_FOLLOWED_ITEM_TYPE_NORMAL

    override fun doAreItemsTheSame(other: AllFollowedItem): Boolean {
        return other is AllFollowedNormalItem && data.id == other.data.id
    }
}