|
@@ -18,6 +18,8 @@ namespace GFGGame
|
|
|
private int _firstChildIndex = 0;//列表显示内容得一个项的显示对象索引
|
|
|
|
|
|
public bool _canShowContent = false;//获取内容数据返回前不可查看
|
|
|
+ public List<MailInfo> mailInfos = new List<MailInfo>();
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
base.Dispose();
|
|
@@ -34,17 +36,17 @@ namespace GFGGame
|
|
|
viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
|
|
|
|
|
|
_ui.m_list.itemRenderer = RenderListItem;
|
|
|
- _ui.m_list.scrollPane.onScrollEnd.Add(OnListScrollEnd);
|
|
|
- _ui.m_list.scrollPane.onScroll.Add(OnListScroll);
|
|
|
_ui.m_list.SetVirtual();
|
|
|
|
|
|
_ui.m_btnGet.onClick.Add(OnClickBtnGet);
|
|
|
_ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
|
|
|
- EventAgent.AddEventListener(ConstMessage.MAIL_REFRESH, () =>
|
|
|
- {
|
|
|
- _ui.m_list.RefreshVirtualList();
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAIL_REFRESH, RefreshList);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAIL_REWARD, RefreshList);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAIL_ALLREWARD, UpdateNormal);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAIL_DELETE, UpdateNormal);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAIL_AllDELETE, UpdateNormal);
|
|
|
EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
|
|
|
|
|
|
mailDataMgr = MailDataManager.Instance;
|
|
@@ -68,62 +70,57 @@ namespace GFGGame
|
|
|
|
|
|
private void RenderListItem(int index, GObject obj)
|
|
|
{
|
|
|
- int childIndex = _ui.m_list.ItemIndexToChildIndex(index);
|
|
|
UI_ListItem item = UI_ListItem.Proxy(obj);
|
|
|
- if (mailDataMgr.mailInfos.Count == 0) return;
|
|
|
- MailInfo data = mailDataMgr.mailInfos[childIndex];
|
|
|
+ if (index + 1 > mailInfos.Count) return;
|
|
|
+ MailInfo data = mailInfos[index];
|
|
|
+
|
|
|
item.m_c1.selectedIndex = mailDataMgr.GetMailState(data);
|
|
|
- item.m_txtTitle.text = data.title;// string.Format("{0}...", data.content.Length > 10 ? data.content.Substring(0, 10) : data.content);
|
|
|
+ item.m_txtTitle.text = data.title;
|
|
|
string str = TimeUtil.FormattingTime(TimeHelper.ServerNowSecs, ((int)data.timeSec + _retainDay * TimeUtil.SECOND_PER_DAY));
|
|
|
item.m_txtTime.text = string.Format("剩余时间:{0}", str);
|
|
|
- if (item.target.data == null)
|
|
|
+ if (item.m_btnLook.data == null)
|
|
|
{
|
|
|
item.m_btnLook.onClick.Add(OnClickBtnLook);
|
|
|
}
|
|
|
- item.target.data = index;
|
|
|
item.m_btnLook.data = index;
|
|
|
|
|
|
}
|
|
|
private async void OnClickBtnLook(EventContext context)
|
|
|
{
|
|
|
- if (!_canShowContent) return;
|
|
|
int index = (int)(context.sender as GObject).data;
|
|
|
- int childIndex = (int)_ui.m_list.ItemIndexToChildIndex(index);
|
|
|
- bool result = await MailSProxy.ReqMailContent(mailDataMgr.mailInfos[childIndex].mailId);
|
|
|
+
|
|
|
+ bool result = await MailSProxy.ReqMailContent(mailInfos[index].mailId);
|
|
|
if (result)
|
|
|
{
|
|
|
- ViewManager.Show<MailContentView>(childIndex);
|
|
|
+ ViewManager.Show<MailContentView>(mailInfos[index].mailId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void OnListScroll()
|
|
|
- {
|
|
|
- _canShowContent = false;
|
|
|
- }
|
|
|
- private void OnListScrollEnd()
|
|
|
- {
|
|
|
- _firstChildIndex = (int)_ui.m_list.GetChildAt(0).data;
|
|
|
- RefreshMailInfo(_firstChildIndex, false);
|
|
|
- }
|
|
|
-
|
|
|
private async void RefreshMailInfo(int index, bool needSort)
|
|
|
{
|
|
|
- bool result = await MailSProxy.ReqMailList(index, _showCount, needSort);
|
|
|
+ if (mailDataMgr.TotolCount == 0) return;
|
|
|
+ if (needSort)
|
|
|
+ {
|
|
|
+ _ui.m_list.ScrollToView(0);
|
|
|
+ }
|
|
|
+ bool result = await MailSProxy.ReqMailList(index, mailDataMgr.TotolCount, needSort);
|
|
|
if (result)
|
|
|
{
|
|
|
- _ui.m_list.RefreshVirtualList();
|
|
|
+ mailInfos = mailDataMgr.GetMailInfos(index, mailDataMgr.TotolCount);
|
|
|
+ RefreshList();
|
|
|
_canShowContent = true;
|
|
|
}
|
|
|
}
|
|
|
+ private void RefreshList()
|
|
|
+ {
|
|
|
+ _ui.m_list.RefreshVirtualList();
|
|
|
|
|
|
- private async void OnClickBtnGet()
|
|
|
+ }
|
|
|
+ private void OnClickBtnGet()
|
|
|
{
|
|
|
- bool result = await MailSProxy.ReqAllMailRewards();
|
|
|
- if (result)
|
|
|
- {
|
|
|
- RefreshMailInfo(_firstChildIndex, false);
|
|
|
- }
|
|
|
+ MailSProxy.ReqAllMailRewards().Coroutine();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void OnClickBtnDelete()
|
|
@@ -133,14 +130,10 @@ namespace GFGGame
|
|
|
SendDeleteAll();
|
|
|
});
|
|
|
}
|
|
|
- private async void SendDeleteAll()
|
|
|
+ private void SendDeleteAll()
|
|
|
{
|
|
|
- bool result = await MailSProxy.ReqDeleteAllMails();
|
|
|
- if (result)
|
|
|
- {
|
|
|
- _ui.m_list.ScrollToView(0);
|
|
|
- RefreshMailInfo(0, true);
|
|
|
- }
|
|
|
+ MailSProxy.ReqDeleteAllMails().Coroutine();
|
|
|
+
|
|
|
}
|
|
|
protected override void OnHide()
|
|
|
{
|