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

190 lines
6.6 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.gh.gamecenter.entity
import android.os.Parcelable
import com.gh.common.filter.RegionSettingHelper
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.WelfareInfo
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlin.math.max
import kotlin.math.min
/**
* Created by LGT on 2016/7/1.
*/
@Parcelize
data class SubjectEntity(
@SerializedName("_id", alternate = ["link_id"])
var id: String? = null,
var name: String? = null,
var more: Int? = null,
@SerializedName("order")
var isOrder: Boolean = false,
var home: String? = null,
var tag: String? = null,
var sort: Int = 0,
@SerializedName("data")
private var mData: MutableList<GameEntity>? = null,
@SerializedName("type", alternate = ["link_type"])
var type: String? = null,
var des: String? = null,
@SerializedName("relation_column_id")
var relatedColumnId: String? = null,
var style: String? = "", // 值为 "top" 时表示此专题(合集)为排行榜 https://gitlab.ghzs.com/pm/halo-app-issues/issues/699
@SerializedName("list")
private val _list: Int? = null,
@SerializedName("common_collection_content")
var commonCollectionList: MutableList<CommonCollectionContentEntity>? = null,
@SerializedName("home_page_style")
var homePageStyle: String = "", //首页样式 横排滑动horizontal_sliding 竖排一行两个1-2
@SerializedName("vertical_line")
var verticalLine: String = "", // 竖排时才有数据,代表竖排行数控制
@SerializedName("game_list_collection")
var gameListCollection: List<HomeGameCollectionEntity>? = null,
@SerializedName("column_test_v2_data")
val testV2Data: HomeItemTestV2Entity? = null,
@SerializedName("show_name")
var showName: Boolean = true, // 是否显示“专题名字”true、false
@SerializedName("type_style")
var typeStyle: String = "", // 横屏样式不显示default、评分star、备注remark
@SerializedName("brief_style")
var briefStyle: String = "", // 简介样式,大小+简介size&brief、评分+简介star&brief、评分star、推荐优先recommend
@SerializedName("more_link")
var moreLink: LinkEntity? = null,
// 开测表部分字段
@SerializedName("index_right_top")
var indexRightTop: String? = null,
@SerializedName("index_right_top_link")
var indexRightTopLink: LinkEntity? = null,
var remark: String? = null, // 开测表备注
var image: String = "",
@SerializedName("first_line_recommend")
var firstLineRecommend: String = "",
@SerializedName("second_line_recommend")
var secondLineRecommend: String = "",
@SerializedName("recommend_tag")
var recommendTag: String = "",
@SerializedName("column_name")
var columnName: String = "",
// 专题合集,用于首页专题合集-排行榜样式
var columns: MutableList<SubjectEntity> = mutableListOf(),
// 专题背景,用于首页专题合集-排行榜样式
var background: String = "",
// 专题内游戏item是否显示下载按钮(目前只针对横向专题)
@SerializedName("show_download")
var showDownload: Boolean = false,
@SerializedName("ad_icon_active")
var adIconActive: Boolean = false,
@SerializedName("link_text")
var linkText: String = "",
@SerializedName("display_content")
var displayContent: String = "",
@SerializedName("recommend_text")
var recommendText: String = "",
@SerializedName("link_game")
var linkGame: GameEntity? = null,
var position: Int = -1,
// 本地字段,用来标记在外部页面中的序号,仅用于曝光记录,具体细节可见 https://git.ghzs.com/pm/halo-app-issues/-/issues/1087
var outerSequence: Int = -1,
@SerializedName("is_qq_column")
var isQQColumn: Boolean = false,
@SerializedName("is_wechat_column")
var isWechatColumn: Boolean = false,
var isWechatColumnCPM: Boolean = false,
var explain: String = "", // 游戏单合集说明
@SerializedName("show_star")
private val _showStar: Boolean? = null,
@SerializedName("home_text")
val homeText: String? = null,
@SerializedName("show_index_subtitle")
val showIndexSubtitle: Boolean = false,
@SerializedName("show_index_icon_subscript")
val showIndexIconSubscript: Boolean = false,
@SerializedName("welfare_info")
val welfareInfo: WelfareInfo? = null,
@SerializedName("column_type")
private val _columnType: String? = null,
@SerializedName("size")
private val _size: Size? = null,
@SerializedName("onlyFee")
private val _onlyFee: Boolean? = false,
) : Parcelable {
@IgnoredOnParcel
var data: MutableList<GameEntity>?
get() = filteredData ?: RegionSettingHelper.filterGame(mData).also { filteredData = it }
set(value) {
mData = RegionSettingHelper.filterGame(value).also { filteredData = it }
}
@IgnoredOnParcel
private var filteredData: MutableList<GameEntity>? = null
val subjectType: SubjectData.SubjectType
get() = when {
isQQColumn -> SubjectData.SubjectType.QQ_GAME
isWechatColumnCPM -> SubjectData.SubjectType.WECHAT_GAME_CPM
isWechatColumn -> SubjectData.SubjectType.WECHAT_GAME
else -> SubjectData.SubjectType.NORMAL
}
val isMiniGame: Boolean get() = isQQColumn || isWechatColumn
val showStar: Boolean
get() = _showStar ?: false
fun getFilterName(): String {
return if (name == null) "" else name!!
}
val list: Int
get() = max(min(_list ?: 0, data?.size ?: 0), 1)
val columnType: String
get() = _columnType ?: ""
val size: Size
get() = _size ?: Size()
val onlyFee: Boolean
get() = _onlyFee ?: false
var isDspSubject: Boolean = false
companion object {
const val SUBJECT_TAG_UPDATE = "update" // 更新时间
const val SUBJECT_TAG_TYPE = "type" // 游戏标签
const val SUBJECT_TAG_TEST = "test" // 开测时间
const val SUBJECT_TAG_SELLING_POINT = "selling_points&type" // 卖点文案+游戏标签
}
@Parcelize
data class Size(
@SerializedName("index")
private val _index: Int? = null,
@SerializedName("limit")
private val _limit: Int? = null,
) : Parcelable {
val index: Int
get() = _index ?: 0
val limit: Int
get() = _limit ?: -1
}
}