|
- local AutoUpdaterView = {};
- AutoUpdaterView.__index = AutoUpdaterView;
-
- --[[
- 自动更新的界面,只显示内容,不做任何逻辑处理
- -- ]]
-
- -- 创建新对象
- function AutoUpdaterView:new(...)
- local instance = {}
- setmetatable(instance , AutoUpdaterView)
- instance:ctor(...)
- return instance
- end
-
- function AutoUpdaterView:ctor(updater , mainScene)
- self.MainScene = mainScene
- self:onEnter()
- end
-
- function AutoUpdaterView:onEnter()
-
- local uiFile
- if isReviewWithMiniGame() then
- uiFile = getMiniGameAutoUpdateViewUI()
- else
- uiFile = "preload/res/preload_gengxin.ui"
- end
- if not uiFile then
- error("Can not found AutoUpdateViewUI")
- end
- self.ui = loadUI(uiFile)
-
- --检查更新
- self.ui.Items.Layout_Loading:setVisible(false)
- self.ui.Items.ImageView_ring:playClip("rotate")
- self.ui.Items.ImageView:playClip("roateNi")
- self.ui.Items.Text_Intro:setString("连接中...")
-
- --进度
- self.ui.Items.Layout_Progress:setVisible(false)
- self.ui.Items.Text_jindu:setString("")
- self.MainScene:addChild(self.ui);
-
- self:showLoading("连接中...")
- end
-
- function AutoUpdaterView:onExit()
- if tolua.isnull(self.ui) then
- return
- end
- self.ui:removeFromParent();
- end
-
- -- 显示加载中
- function AutoUpdaterView:showLoading(strMessage)
- logD("AutoUpdaterView:showLoading()", tostring(strMessage));
-
- -- 小游戏审核的时候不要显示网络连接
- if isReviewWithMiniGame() then
- return
- end
-
- self.ui.Items.Layout_Loading:setVisible(true)
- self.ui.Items.Layout_Progress:setVisible(false)
-
- self.ui.Items.Text_Intro:setString(tostring(strMessage));
- end
-
- -- 显示进度条
- function AutoUpdaterView:showProgress(eventName , eventValue)
- logD("AutoUpdaterView:showProgress()", tostring(eventName));
-
- self.ui.Items.Layout_Loading:setVisible(false)
- self.ui.Items.Layout_Progress:setVisible(true)
-
- if eventValue then
- if type(eventValue) == "table" then
- logD("AutoUpdaterView:onEvent()", eventValue.percent, eventValue.text);
- self.ui.Items.Text_jindu:setString(tostring(eventValue.text or ""));
- self.ui.Items.Slider:setPercent(tonumber(eventValue.percent or 0) * 100);
- else
- logD("AutoUpdaterView:onEvent()", tostring(eventValue));
- self.ui.Items.Text_jindu:setString(tostring(eventValue));
- end
- end
- end
-
- -- 更新事件
- function AutoUpdaterView:onEvent(eventName , eventValue)
-
- if tolua.isnull(self.ui.Items.Text_Intro) then
- return
- end
-
- if eventValue then
- if type(eventValue) == "table" then
- logD("AutoUpdaterView:onEvent()", eventValue.percent, eventValue.text);
- self.ui.Items.Text_jindu:setString(tostring(eventValue.text or ""));
- self.ui.Items.Slider:setPercent(tonumber(eventValue.percent or 0) * 100);
- else
- logD("AutoUpdaterView:onEvent()", tostring(eventValue));
- self.ui.Items.Text_Intro:setString(tostring(eventValue));
- end
- end
- end
-
- return AutoUpdaterView;
|