local ActivityCell = class("ActivityCell", BaseCell)
local REWARD_CELL_COUNT = 3

function ActivityCell:refresh(actId, callback)
    local actCfg = ConfigManager:getConfig("activity")[actId]
    local showReward = actCfg.show_reward
    
    local uiMap = self:getUIMap()
    local banner = uiMap["activity_cell.banner"]
    local timeTx = uiMap["activity_cell.banner.time_tx"]
    local titleTx = uiMap["activity_cell.banner.title_tx"]
    if not self.rewardList then
        self.rewardList = {}
        for i = 1, REWARD_CELL_COUNT do
            table.insert(self.rewardList, CellManager:addCellComp(uiMap["activity_cell.banner.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL))
        end
    end
    local redPoint = uiMap["activity_cell.banner.red_point"]

    -- 刷新
    banner:setTexture(GConst.ActSprintConst.ACT_LIST_BANNER[actId])
    timeTx:setText(Time:formatNumTimeStr(DataManager.ActSprintData:getRemainTime(actId)))
    titleTx:setText(I18N:getGlobalText(GConst.ActSprintConst.ACT_LIST_NAME[actId]))
    for i = 1, REWARD_CELL_COUNT do
        if showReward and i <= #showReward then
            self.rewardList[i].baseObject:setActive(true)
            self.rewardList[i]:refreshByConfig(showReward[i])
        else
            self.rewardList[i].baseObject:setActive(false)
        end
    end
    self:addClickListener(function()
        ModuleManager.ActSprintManager:showActSprintMainUI({actId = actId})
        -- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_ACT_SPRINT_LIST_UI)
        if callback then
            callback()
        end
    end)
    redPoint:setVisible(DataManager.ActSprintData:hasRedPoint(true))
end

return ActivityCell