--[[ 通知的设置界面 ]] local UISettingNoticePanel = UIViewClass() function UISettingNoticePanel:OnCreated() self.scrollRectDatas = {} self.offLinePushIds = {} end local function SortFunc(a, b) return a.SortId < b.SortId end function UISettingNoticePanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_NotificationStateChange, self.NotificationStateChange) self:RegistSystemEvent(EventID.UI_ServerNotificationStateChange, self.ServerNotificationStateChange) self.btn_ReleaseMusooSkill.isOn = CTL.Notification.IsTotalNoticeOpen() local offLinePushDatas = {} for __, pushCfgData in DataSheetManager.AppPush:GetEnumerator() do if self:IsShowInScroll(pushCfgData) then if pushCfgData.Fuction == LuaConst.ActivityType.HeroMatch1v1 then if MDL.HeroMatch1v1.IsShowHeroMatch1v1Entry() then table.insert(self.scrollRectDatas, pushCfgData) end elseif pushCfgData.Fuction == LuaConst.ActivityType.HeroMatch3v3 then if MDL.HeroMatch3v3.IsShowHeroMatch3v3Entry() then table.insert(self.scrollRectDatas, pushCfgData) end elseif pushCfgData.Fuction == LuaConst.ActivityType.FairSoloTournament then if MDL.FairSoloTournament.IsShowEntry() then table.insert(self.scrollRectDatas, pushCfgData) end elseif pushCfgData.Fuction == LuaConst.ActivityType.TeamFairChampionship then if CTL.TeamFairChampionship.IsShowEntry() then table.insert(self.scrollRectDatas, pushCfgData) end elseif pushCfgData.Class == 9 or pushCfgData.Class == 10 then table.insert(offLinePushDatas, pushCfgData) else table.insert(self.scrollRectDatas, pushCfgData) end end end table.sort(self.scrollRectDatas, SortFunc) table.sort(offLinePushDatas, SortFunc) table.insert(self.offLinePushIds, MDL.Notification.ConstPushID.TiLi) table.insert(self.offLinePushIds, MDL.Notification.ConstPushID.GuaJi) for i,v in ipairs(offLinePushDatas) do table.insert(self.offLinePushIds, v.ID) end self.LoopScroll:ReloadAll(self.scrollRectDatas) self.OffLine_LoopScroll:ReloadAll(self.offLinePushIds) MDL.Notification.GetAppPushSwitchInfoReq() end function UISettingNoticePanel:NotificationStateChange() self.btn_ReleaseMusooSkill.isOn = CTL.Notification.IsTotalNoticeOpen() end function UISettingNoticePanel:ServerNotificationStateChange() self.updateServerState = true self.OffLine_LoopScroll:RefreshCells() self.updateServerState = nil end function UISettingNoticePanel:OnClosed() MDL.Notification.SaveNotificationData() end function UISettingNoticePanel:IsShowInScroll(pushCfgData) if pushCfgData.IsShow == 0 then return false end if pushCfgData.Class == MDL.Notification.PushType.TiLi then return false end if pushCfgData.Class == MDL.Notification.PushType.GuaJi then return false end return true end function UISettingNoticePanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll then UIUtils.SetLabelText(cellTable.lab_Bgm, Const_IDS[data.ShowTitle]) if data.Class == MDL.Notification.PushType.Activity then local activityCfgData = DataSheetManager.ActivityData:GetDataByID(data.Fuction) local date, time = UTL.Time.GetDateDescAndTime(activityCfgData.Time_Table) UIUtils.SetLabel(cellTable.lab_times, date) UIUtils.SetLabel(cellTable.lab_time, time) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data.ID) elseif data.Fuction == LuaConst.ActivityType.HeroMatch1v1 or data.Fuction == LuaConst.ActivityType.HeroMatch3v3 then local activityCfgData = DataSheetManager.ActivityData:GetDataByID(data.Fuction) local date, time, extra = CTL.Activities.GetDetailsTimeDesc(activityCfgData, true) UIUtils.SetLabel(cellTable.lab_times, date) UIUtils.SetLabel(cellTable.lab_time, time) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data.ID) elseif data.Fuction == LuaConst.ActivityType.FairSoloTournament or data.Fuction == LuaConst.ActivityType.TeamFairChampionship then local activityCfgData = DataSheetManager.ActivityData:GetDataByID(data.Fuction) local date, time, extra = CTL.Activities.GetDetailsTimeDesc(activityCfgData, true) UIUtils.SetLabel(cellTable.lab_times, date) UIUtils.SetLabel(cellTable.lab_time, time) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data.ID) elseif data.Fuction == LuaConst.ActivityType.GuildMine or data.Class == MDL.Notification.PushType.ServerNotice then UIUtils.SetLabel(cellTable.lab_times, nil) UIUtils.SetLabel(cellTable.lab_time, nil) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data.ID) else local date, time = UTL.Time.GetDateDescAndTime({tonumber(data.TimeStart)}) UIUtils.SetLabel(cellTable.lab_times, date) UIUtils.SetLabel(cellTable.lab_time, time) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data.ID) end elseif scrollRect == self.OffLine_LoopScroll then if data == MDL.Notification.ConstPushID.TiLi then UIUtils.SetLabelText(cellTable.lab_Bgm, Const_IDS.IDS_APPPUSH_HANGUP) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(MDL.Notification.ConstPushID.TiLi) elseif data == MDL.Notification.ConstPushID.GuaJi then UIUtils.SetLabelText(cellTable.lab_Bgm, Const_IDS.IDS_APPPUSH_ACTIVITY) cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(MDL.Notification.ConstPushID.GuaJi) else local pushCfgData = DataSheetManager.AppPush:GetDataByID(data) UIUtils.SetLabelText(cellTable.lab_Bgm, Const_IDS[pushCfgData.ShowTitle]) if pushCfgData.Class == MDL.Notification.PushType.ServerNotice then if self.updateServerState then cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data) end else cellTable.btn_BGM.isOn = MDL.Notification.GetNotificationEnabled(data) end end end end function UISettingNoticePanel:OnCellValueChanged(scrollRect, index, cellTable, target, value) if scrollRect == self.LoopScroll then local pushCfgData = self.scrollRectDatas[index+1] if pushCfgData then MDL.Notification.SetNotificationEnabled(pushCfgData.ID, value) end elseif scrollRect == self.OffLine_LoopScroll then local id = self.offLinePushIds[index+1] MDL.Notification.SetNotificationEnabled(id, value) end end function UISettingNoticePanel:OnValueChanged(comp, value) if comp == self.btn_ReleaseMusooSkill then if value ~= CTL.Notification.IsTotalNoticeOpen() then self.btn_ReleaseMusooSkill.isOn = CTL.Notification.IsTotalNoticeOpen() CTL.Notification.GoToSysSetting() end end end return UISettingNoticePanel