package com.gh.gamecenter.feature.entity

import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName

/**
 * Created by khy on 2016/8/17.
 */
class ConcernEntity() : Parcelable {

    @SerializedName("_id")
    var id: String? = null

    @SerializedName("game_name")
    private var gameName: String? = null

    @SerializedName("name_suffix")
    var nameSuffix: String? = ""

    @SerializedName("game_icon")
    var gameIcon: String? = null

    var game: SimpleGame? = null

    var title: String? = null

    var content: String? = null

    var time: Long = 0

    var img: List<String>? = null

    var link: String? = null

    var brief: String? = null

    var views: Int = 0

    var commentnum: Int = 0

    var type: String? = null

    @SerializedName("game_id")
    var gameId: String? = null

    var platform: String? = null

    var name: String? = null

    @SerializedName("me")
    var me: MeEntity? = null

    @SerializedName("_seq")
    var shortId: String? = null

    fun getGameName(): String {
        return game?.name ?: ""
    }

    constructor(parcel: Parcel) : this() {
        id = parcel.readString()
        gameName = parcel.readString()
        gameIcon = parcel.readString()
        title = parcel.readString()
        content = parcel.readString()
        time = parcel.readLong()
        img = parcel.createStringArrayList()
        link = parcel.readString()
        brief = parcel.readString()
        views = parcel.readInt()
        commentnum = parcel.readInt()
        type = parcel.readString()
        gameId = parcel.readString()
        platform = parcel.readString()
        name = parcel.readString()
        me = parcel.readParcelable(MeEntity::class.java.classLoader)
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(gameName)
        parcel.writeString(gameIcon)
        parcel.writeString(title)
        parcel.writeString(content)
        parcel.writeLong(time)
        parcel.writeStringList(img)
        parcel.writeString(link)
        parcel.writeString(brief)
        parcel.writeInt(views)
        parcel.writeInt(commentnum)
        parcel.writeString(type)
        parcel.writeString(gameId)
        parcel.writeString(platform)
        parcel.writeString(name)
        parcel.writeParcelable(me, flags)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object {

        const val TAG = "ConcernEntity"

        @JvmField
        val CREATOR: Parcelable.Creator<ConcernEntity> = object : Parcelable.Creator<ConcernEntity> {
            override fun createFromParcel(source: Parcel): ConcernEntity {
                return ConcernEntity(source)
            }

            override fun newArray(size: Int): Array<ConcernEntity?> {
                return arrayOfNulls(size)
            }
        }
    }

}
