/// <summary> /// 显示群列表 /// </summary> /// <param name="lst"></param> public void ShowGroupList(List <ChatGroupEntity> lst) { SetPageActive(lst.Count > 0 ? m_ExistGroup : m_NoneGroupPage); if (lst == null || lst.Count == 0) { return; } for (int i = 0; i < m_GroupList.Count; ++i) { UIItemChatGroup item = m_GroupList[i]; UIPoolManager.Instance.Despawn(item.transform); } m_GroupList.Clear(); for (int i = 0; i < lst.Count; ++i) { ChatGroupEntity group = lst[i]; UIItemChatGroup item = UIPoolManager.Instance.Spawn("UIItemChatGroup").GetComponent <UIItemChatGroup>(); item.gameObject.SetParent(m_ChatGroupContainer); item.SetUI(group.id, group.name, group.avatar /*GetChatGroupHead(group.avatarIndex)*/, group.currMemberCount, group.maxMemberCount, group.roomCount); item.SetSelect(false); item.SetNewTip(group.hasNewApply); m_GroupList.Add(item); } }
/// <summary> /// 添加新群 /// </summary> /// <param name="data"></param> private void OnAddGroup(TransferData data) { SetPageActive(m_ExistGroup); ChatGroupEntity group = data.GetValue <ChatGroupEntity>("ChatGroup"); UIItemChatGroup item = UIPoolManager.Instance.Spawn("UIItemChatGroup").GetComponent <UIItemChatGroup>(); item.gameObject.SetParent(m_ChatGroupContainer); item.SetUI(group.id, group.name, group.avatar /*GetChatGroupHead(group.avatarIndex)*/, group.currMemberCount, group.maxMemberCount, group.roomCount); item.SetSelect(false); item.SetNewTip(group.hasNewApply); m_GroupList.Add(item); }
/// <summary> /// 移除群 /// </summary> /// <param name="data"></param> private void OnRemoveGroup(TransferData data) { ChatGroupEntity group = data.GetValue <ChatGroupEntity>("ChatGroup"); for (int i = 0; i < m_GroupList.Count; ++i) { if (group.id == m_GroupList[i].GroupId) { UIItemChatGroup item = m_GroupList[i]; UIPoolManager.Instance.Despawn(item.transform); m_GroupList.Remove(item); break; } } if (group.id == m_GroupId) { for (int i = 0; i < m_MemberList.Count; ++i) { UIPoolManager.Instance.Despawn(m_MemberList[i].transform); } m_MemberList.Clear(); for (int i = 0; i < m_RoomList.Count; ++i) { UIPoolManager.Instance.Despawn(m_RoomList[i].transform); } m_RoomList.Clear(); for (int i = 0; i < m_RecordList.Count; ++i) { UIPoolManager.Instance.Despawn(m_RecordList[i].transform); } m_RecordList.Clear(); for (int i = 0; i < m_RoomPlayerList.Count; ++i) { UIPoolManager.Instance.Despawn(m_RoomPlayerList[i].transform); } m_RoomPlayerList.Clear(); for (int i = 0; i < m_MessageList.Count; ++i) { UIPoolManager.Instance.Despawn(m_MessageList[i].transform); } m_MessageList.Clear(); } if (m_GroupList.Count == 0) { m_NoneGroupPage.gameObject.SetActive(true); } if (m_GroupId == group.id) { m_GroupId = 0; m_MemberListPage.gameObject.SetActive(false); m_GroupInfoPage.gameObject.SetActive(false); m_DefaultPageRight.gameObject.SetActive(true); } SetPageActive(m_GroupList.Count > 0 ? m_ExistGroup : m_NoneGroupPage); }