|
@@ -14,10 +14,13 @@ namespace GFGGame
|
|
|
private MailDataManager mailDataMgr;
|
|
|
private const int _maxMailCount = 300;
|
|
|
private const int _retainDay = 30;//邮件保存时间
|
|
|
- private const int _showCount = 5;//列表展示数量
|
|
|
+ // private const int _showCount = 5;//?б???????
|
|
|
+
|
|
|
+ private int _firstPage = 0;//当前页面
|
|
|
+ private int _endPage = 0;//当前页面
|
|
|
|
|
|
public bool _canShowContent = false;//获取内容数据返回前不可查看
|
|
|
- public List<MailInfo> mailInfos = new List<MailInfo>();
|
|
|
+ public List<MailInfo> mailInfos;//= new List<MailInfo>();
|
|
|
|
|
|
public override void Dispose()
|
|
|
{
|
|
@@ -36,6 +39,14 @@ namespace GFGGame
|
|
|
|
|
|
_ui.m_list.itemRenderer = RenderListItem;
|
|
|
_ui.m_list.SetVirtual();
|
|
|
+ _ui.m_list.scrollPane.onScrollEnd.Add(() =>
|
|
|
+ {
|
|
|
+ RefreshMailInfo(false);
|
|
|
+ });
|
|
|
+ // _ui.target.onTouchEnd.Add(() =>
|
|
|
+ // {
|
|
|
+ // RefreshMailInfo(false);
|
|
|
+ // });
|
|
|
|
|
|
_ui.m_btnGet.onClick.Add(OnClickBtnGet);
|
|
|
_ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
|
|
@@ -54,7 +65,7 @@ namespace GFGGame
|
|
|
protected override void OnShown()
|
|
|
{
|
|
|
base.OnShown();
|
|
|
-
|
|
|
+ mailDataMgr.CurPage = 0;
|
|
|
UpdateNormal();
|
|
|
}
|
|
|
private void UpdateNormal()
|
|
@@ -63,14 +74,27 @@ namespace GFGGame
|
|
|
_ui.m_txtTips.visible = mailDataMgr.TotolCount == 0 ? true : false;
|
|
|
_ui.m_txtCount.text = string.Format("当前邮件:{0}/{1}", StringUtil.GetColorText(mailDataMgr.TotolCount.ToString(), mailDataMgr.TotolCount >= _maxMailCount ? "#B19977" : "#E27D78"), _maxMailCount);
|
|
|
_ui.m_txtMaxCount.text = string.Format("最高可储存{0}封邮箱,请及时查看", _maxMailCount);
|
|
|
- RefreshMailInfo(0, true);
|
|
|
+ RefreshMailInfo(true);
|
|
|
}
|
|
|
|
|
|
private void RenderListItem(int index, GObject obj)
|
|
|
{
|
|
|
+ // _endPage = index / mailDataMgr.PageCount;
|
|
|
+ // ET.Log.Debug("_endPage:" + _endPage + " index:" + index + " PageCount:" + mailDataMgr.PageCount);
|
|
|
+
|
|
|
UI_ListItem item = UI_ListItem.Proxy(obj);
|
|
|
- if (index + 1 > mailInfos.Count) return;
|
|
|
- MailInfo data = mailInfos[index];
|
|
|
+
|
|
|
+ long mailId = mailDataMgr.GetMailIdByIndex(index);
|
|
|
+ // item.m_btnLook.data = mailId;
|
|
|
+ if (mailId < 0)
|
|
|
+ {
|
|
|
+ item.m_txtTitle.text = "请稍后...";
|
|
|
+ item.m_txtTime.text = "";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // long mailId = mailDataMgr.MailIds[index];
|
|
|
+ MailInfo data = mailDataMgr.GetMailInfoById(mailId);
|
|
|
|
|
|
item.m_c1.selectedIndex = mailDataMgr.GetMailState(data);
|
|
|
item.m_txtTitle.text = data.title;
|
|
@@ -80,38 +104,61 @@ namespace GFGGame
|
|
|
{
|
|
|
item.m_btnLook.onClick.Add(OnClickBtnLook);
|
|
|
}
|
|
|
- item.m_btnLook.data = index;
|
|
|
+ item.m_btnLook.data = mailId;
|
|
|
|
|
|
+ UI_ListItem.ProxyEnd();
|
|
|
}
|
|
|
private async void OnClickBtnLook(EventContext context)
|
|
|
{
|
|
|
- int index = (int)(context.sender as GObject).data;
|
|
|
-
|
|
|
- bool result = await MailSProxy.ReqMailContent(mailInfos[index].mailId);
|
|
|
+ // int index = (int)(context.sender as GObject).data;
|
|
|
+ long mailId = (long)(context.sender as GObject).data;
|
|
|
+ bool result = await MailSProxy.ReqMailContent(mailId);
|
|
|
if (result)
|
|
|
{
|
|
|
- ViewManager.Show<MailContentView>(mailInfos[index].mailId);
|
|
|
+ ViewManager.Show<MailContentView>(mailId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- private async void RefreshMailInfo(int index, bool needSort)
|
|
|
+ private async void RefreshMailInfo(bool needSort)
|
|
|
{
|
|
|
if (mailDataMgr.TotolCount == 0) return;
|
|
|
if (needSort)
|
|
|
{
|
|
|
_ui.m_list.ScrollToView(0);
|
|
|
+ MailDataManager.Instance.RefreshMailInfoDic(needSort);
|
|
|
}
|
|
|
- bool result = await MailSProxy.ReqMailList(index, mailDataMgr.TotolCount, needSort);
|
|
|
- if (result)
|
|
|
+ _firstPage = _ui.m_list.ChildIndexToItemIndex(0) / mailDataMgr.PageCount;
|
|
|
+ _endPage = _ui.m_list.ChildIndexToItemIndex(_ui.m_list.numChildren - 1) / mailDataMgr.PageCount;
|
|
|
+ ET.Log.Debug("_firstPage:" + _firstPage + " _endPage:" + _endPage);
|
|
|
+ if (mailDataMgr.GetMailIdByPage(_firstPage) != null && mailDataMgr.GetMailIdByPage(_endPage) != null)
|
|
|
{
|
|
|
- mailInfos = mailDataMgr.GetMailInfos(index, mailDataMgr.TotolCount);
|
|
|
RefreshList();
|
|
|
- _canShowContent = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mailDataMgr.GetMailIdByPage(_firstPage) == null)
|
|
|
+ {
|
|
|
+ bool result = await MailSProxy.ReqMailList(_firstPage * mailDataMgr.PageCount, mailDataMgr.PageCount, needSort, _firstPage);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ RefreshList();
|
|
|
+ }
|
|
|
}
|
|
|
+ if (_endPage == _firstPage) return;
|
|
|
+
|
|
|
+ if (mailDataMgr.GetMailIdByPage(_endPage) == null)
|
|
|
+ {
|
|
|
+ bool result = await MailSProxy.ReqMailList(_endPage * mailDataMgr.PageCount, mailDataMgr.PageCount, needSort, _endPage);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ RefreshList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
private void RefreshList()
|
|
|
{
|
|
|
+ // mailInfos = mailDataMgr.GetMailInfos();
|
|
|
_ui.m_list.RefreshVirtualList();
|
|
|
|
|
|
}
|