This commit is contained in:
2020-08-07 07:27:09 +08:00
parent 113faa50ce
commit 0fd1912998
21 changed files with 578 additions and 56 deletions

View File

@@ -5,6 +5,8 @@ local csSelf = nil
local transform = nil
local mData = nil
local uiobjs = {}
local isDownLoading = false
local www
-- 初始化,只调用一次
function _cell.init(csObj)
@@ -13,14 +15,29 @@ function _cell.init(csObj)
uiobjs.Label = getCC(transform, "Label", "UILabel")
uiobjs.ButtonDel = getChild(transform, "ButtonDel").gameObject
uiobjs.SpriteIcon = getCC(transform, "SpriteIcon", "UISprite")
uiobjs.ButtonDownload = getChild(transform, "ButtonDownload").gameObject
uiobjs.DownloadProgress = getChild(transform, "DownloadProgress")
uiobjs.DownloadProgressLb = getCC(uiobjs.DownloadProgress, "Label", "UILabel")
end
-- 显示,
-- 注意c#侧不会在调用show时调用refresh
function _cell.show(go, data)
mData = data
SetActive(uiobjs.ButtonDel, false)
uiobjs.Label.text = mData.name
if MyUtl.isImage(mData.name) then
--//TODO:
else
end
--//TODO:权限判断,如果有权限的可以考虑直接显示图片
if DBTextures.hadDownloaded(mData.name) then
SetActive(uiobjs.ButtonDownload, false)
else
SetActive(uiobjs.ButtonDownload, true)
end
end
-- 取得数据
@@ -28,5 +45,49 @@ function _cell.getData()
return mData
end
function _cell.download()
if isDownLoading then
return
end
isDownLoading = true
SetActive(uiobjs.ButtonDownload, false)
www =
DBTextures.download(
mData.name,
mData.url,
function(content, localPath)
isDownLoading = false
www = nil
if content and localPath then
-- 附件下载完成
MyUtl.toastS(joinStr("附件已保存本地:" .. localPath))
else
SetActive(uiobjs.ButtonDownload, true)
end
end
)
_cell.refreshProgress()
end
function _cell.refreshProgress()
if www == nil then
SetActive(uiobjs.DownloadProgress.gameObject, false)
return
else
SetActive(uiobjs.DownloadProgress.gameObject, true)
local progressVal = www.downloadProgress or 0 -- downloadProgress uploadProgress
uiobjs.LabelPersent.text = joinStr(math.floor(progressVal * 100), "%")
end
csSelf:invoke4Lua(_cell.refreshProgress, 0.1)
end
function _cell.uiEventDelegate(go)
if go.name == "ButtonDownload" then
_cell.download()
end
end
--------------------------------------------
return _cell