local PushSettingData = BaseClass("PushSettingData")
local Localization = CS.GameEntry.Localization
local __init = function(self)
  self.pushSettingList = {}
  self.pushInfoList = {}
end
local __delete = function(self)
  self.pushSettingList = nil
  self.pushInfoList = nil
end
local InitData = function(self, message)
  if message.pushSetting ~= nil then
    self.pushSettingList = {}
    for k, v in pairs(message.pushSetting) do
      self:UpdateOnePushSettingInfo(v)
    end
  end
  if message.fb_push_unlock ~= nil then
    self.pushInfoList = {}
    for k, v in pairs(message.fb_push_unlock) do
      self:UpdateOnePushInfo(v)
    end
  end
end
local UpdateOnePushSettingInfo = function(self, message)
  if message ~= nil and message.type ~= nil then
    local type = message.type
    local one = self:GetPushSettingInfoByType(type)
    if one == nil then
      one = PushSettingInfo.New()
      one:UpdateInfo(message)
      self.pushSettingList[type] = one
    else
      one:UpdateInfo(message)
    end
  end
end
local GetPushSettingInfoByType = function(self, type)
  return self.pushSettingList[type]
end
local UpdateOnePushInfo = function(self, message)
  if message ~= nil and message.id ~= nil then
    local id = message.id
    local one = self:GetPushInfoByType(id)
    if one == nil then
      one = PushSettingInfo.New()
      one:UpdateInfo(message)
      self.pushInfoList[id] = one
    else
      one:UpdateInfo(message)
    end
  end
end
local GetPushInfoByType = function(self, id)
  return self.pushInfoList[id]
end
local IsPushNotify = function(self, type)
  local temp = self:GetPushSettingInfoByType(type)
  if temp ~= nil and temp.status == SettingNoticeStatus.Off then
    return false
  end
  return true
end
local CheckPushUnlock = function(self, id)
  local temp = self:GetPushInfoByType(id)
  if temp ~= nil and temp.unlock == SettingNoticeUnlock.UnLock then
    return true
  end
  return false
end
local ParsePushSetHandle = function(self, message)
  if message.errorCode ~= nil then
    UIUtil.ShowTips(Localization:GetString(message.errorCode))
  else
    self:UpdateOnePushSettingInfo(message)
  end
end
local PushSettingHandle = function(self, message)
  if message.pushSetting ~= nil then
    for k, v in pairs(message.pushSetting) do
      self:UpdateOnePushSettingInfo(v)
    end
  end
end
PushSettingData.__init = __init
PushSettingData.__delete = __delete
PushSettingData.InitData = InitData
PushSettingData.UpdateOnePushSettingInfo = UpdateOnePushSettingInfo
PushSettingData.GetPushSettingInfoByType = GetPushSettingInfoByType
PushSettingData.IsPushNotify = IsPushNotify
PushSettingData.GetPushInfoByType = GetPushInfoByType
PushSettingData.UpdateOnePushInfo = UpdateOnePushInfo
PushSettingData.CheckPushUnlock = CheckPushUnlock
PushSettingData.ParsePushSetHandle = ParsePushSetHandle
PushSettingData.PushSettingHandle = PushSettingHandle
return PushSettingData
