package com.gh.gamecenter.feature.utils

/**
 * 内容拦截帮助类 管理需求 https://jira.shanqu.cc/browse/GHZS-4490
 *
 * "game_tag", // 游戏标签
 * "subtitle", // 副标题
 * "custom_column", // 自定义栏目
 * "icon_subscript" // 图标角标
 */
object ContentBlockedHelper {

    const val GAME_TAG = "game_tag"
    const val SUBTITLE = "subtitle"
    const val CUSTOM_COLUMN = "custom_column"
    const val ICON_SUBSCRIPT = "icon_subscript"

    private var isGameTagBlocked = false
    private var isSubtitleBlocked = false
    private var isCustomColumnBlocked = false
    private var isIconSubscriptBlocked = false

    fun init(blockedTypeList: List<String>) {
        blockedTypeList.forEach {
            when (it) {
                GAME_TAG -> {
                    isGameTagBlocked = true
                }
                SUBTITLE -> {
                    isSubtitleBlocked = true
                }
                CUSTOM_COLUMN -> {
                    isCustomColumnBlocked = true
                }
                ICON_SUBSCRIPT -> {
                    isIconSubscriptBlocked = true
                }
            }
        }
    }

    /**
     * 判断是否需要拦截
     * @param type 内容类型
     */
    fun isContentBlocked(type: String): Boolean {
        if (type == GAME_TAG) {
            return isGameTagBlocked
        } else if (type == SUBTITLE) {
            return isSubtitleBlocked
        } else if (type == CUSTOM_COLUMN) {
            return isCustomColumnBlocked
        } else if (type == ICON_SUBSCRIPT) {
            return isIconSubscriptBlocked
        }

        return false
    }

}