Files
assistant-android/app/src/main/java/com/gh/gamecenter/entity/GamesCollectionEntity.kt

106 lines
3.5 KiB
Kotlin

package com.gh.gamecenter.entity
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.gh.gamecenter.R
import com.gh.gamecenter.feature.entity.MeEntity
import com.gh.gamecenter.feature.entity.SimpleGame
import com.gh.gamecenter.feature.entity.Count
import com.gh.gamecenter.feature.entity.TimeEntity
import com.gh.gamecenter.room.converter.*
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Entity
@Parcelize
data class GamesCollectionEntity(
@PrimaryKey
@SerializedName("_id")
var id: String = "",
@TypeConverters(TagInfoListConverter::class)
var tags: ArrayList<TagInfoEntity>? = null,
@TypeConverters(ActivityLabelListConverter::class)
@SerializedName("activity_tags")
var activityTags: ArrayList<ActivityLabelEntity>? = null,
@TypeConverters(SimpleGameListConverter::class)
var games: ArrayList<SimpleGame>? = null,
var title: String = "",
var intro: String = "",
var cover: String = "",
var display: String = "",//self_only: 仅自己可见
var stamp: String = "",//special_choice: 精选 offical: 官方
@TypeConverters(CountConverter::class)
var count: Count? = null,
@TypeConverters(UserConverter::class)
var user: User? = null,
@TypeConverters(MeConverter::class)
var me: MeEntity? = null,
var orderTag: Long = 0,
@Ignore
var time: TimeEntity? = null,
@Ignore
var status: String = "",// draft/pending/pass/failed
@Ignore
@SerializedName("ad_icon_active")
var adIconActive: Boolean = false,
//本地字段
@Ignore
var isLocalDraft: Boolean = false
) : Parcelable {
fun getStatusLabelRes(): Int {
return when {
display == "self_only" && status == "pass" -> R.drawable.ic_game_collection_private
status == "draft" -> R.drawable.ic_game_collection_draft
status == "pending" -> R.drawable.ic_game_collection_pending
status == "failed" -> R.drawable.ic_game_collection_fail
else -> -1
}
}
fun getTagIds(): String {
val sb = StringBuffer()
tags?.forEach {
sb.append(it.id)
}
return sb.toString()
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as GamesCollectionEntity
// 这里只对比游戏单id判断是否相同
if (id != other.id) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (tags?.hashCode() ?: 0)
result = 31 * result + (activityTags?.hashCode() ?: 0)
result = 31 * result + (games?.hashCode() ?: 0)
result = 31 * result + title.hashCode()
result = 31 * result + intro.hashCode()
result = 31 * result + cover.hashCode()
result = 31 * result + display.hashCode()
result = 31 * result + stamp.hashCode()
result = 31 * result + (count?.hashCode() ?: 0)
result = 31 * result + (user?.hashCode() ?: 0)
result = 31 * result + (me?.hashCode() ?: 0)
result = 31 * result + orderTag.hashCode()
result = 31 * result + (time?.hashCode() ?: 0)
result = 31 * result + status.hashCode()
result = 31 * result + adIconActive.hashCode()
result = 31 * result + isLocalDraft.hashCode()
return result
}
}