Example #1
0
        public void SetUserItemData()
        {
            switch (_chatDataItem.targetType)
            {
            case ChatDataItem.TargetType.SYSTEM:
                UIManager.GetInstance().SetImage(_imageHead, EAtlasName.Chat, "010");
                break;

            case ChatDataItem.TargetType.INDIVIDUAL:
                _userItem = GlobalUser.GetInstance().Self;
                if (_chatDataItem.sendUserId != GlobalUser.GetInstance().UserId)
                {
                    _userItem = GlobalContacts.GetInstance().GetUserItemById(_chatDataItem.sendUserId);
                }

                UIManager.GetInstance().SetImage(_imageHead, EAtlasName.Head, "00" + _userItem.headIndex);
                break;

            case ChatDataItem.TargetType.GROUP:
                _userItem = GlobalGroup.GetInstance().GetGroupMember(_chatDataItem.sendUserId);
                if (_userItem != null)
                {
                    UIManager.GetInstance().SetImage(_imageHead, EAtlasName.Head, "00" + _userItem.headIndex);
                }
                break;

            default:
                break;
            }
        }
        private void InitButtons()
        {
            _buttonAddFriend.gameObject.SetActive(false);
            _buttonDeleteFriend.gameObject.SetActive(false);
            _buttonBeginChat.gameObject.SetActive(false);
            _buttonAddFriend.onClick.RemoveAllListeners();
            _buttonDeleteFriend.onClick.RemoveAllListeners();
            _buttonBeginChat.onClick.RemoveAllListeners();


            if (_userItem.userId == GlobalUser.GetInstance().UserId)
            {
                return;
            }
            else if (GlobalContacts.GetInstance().Contains(_userItem.userId))
            {
                _buttonBeginChat.gameObject.SetActive(true);
                _buttonDeleteFriend.gameObject.SetActive(true);

                _buttonBeginChat.onClick.AddListener(OnClickBeginChatButton);
                _buttonDeleteFriend.onClick.AddListener(OnClickDeleteFriendButton);
            }
            else if (!GlobalContacts.GetInstance().Contains(_userItem.userId))
            {
                _buttonAddFriend.gameObject.SetActive(true);

                _buttonAddFriend.onClick.AddListener(OnClickAddFriendButton);
            }
        }
Example #3
0
        public void RefreshContactsFrames()
        {
            _contactsGrid.GetComponent <RectTransform>().sizeDelta = new Vector2(GlobalVars.DEFAULT_SCREEN_WIDTH, CONTACT_FRAME_HEIGHT * GlobalContacts.GetInstance().Count);

            int i = 0;

            foreach (UserItem userItem in GlobalContacts.GetInstance())
            {
                if (i >= _contactFrameList.Count)
                {
                    GameObject go = UIManager.GetInstance().AddChild(_contactsGrid.gameObject, EUIType.ContactFrame);
                    _contactFrameList.Add(go.GetComponent <ContactFrame>());
                }
                _contactFrameList[i].Show(userItem);
                i++;
            }

            if (_contactFrameList.Count > GlobalContacts.GetInstance().Count)
            {
                for (i = GlobalContacts.GetInstance().Count; i < _contactFrameList.Count; i++)
                {
                    GameObject.Destroy(_contactFrameList[i].gameObject);
                }
                _contactFrameList = _contactFrameList.GetRange(0, GlobalContacts.GetInstance().Count);
            }
        }
        private void InitMemberFrames()
        {
            List <string> groupMemberIDs = new List <string>();

            if (_groupItem != null)
            {
                groupMemberIDs = _groupItem.memberUserId;
            }

            foreach (var friendItem in GlobalContacts.GetInstance())
            {
                GameObject go = UIManager.GetInstance().AddChild(_gridSelectMember.gameObject, EUIType.GroupMemberFrame);
                go.GetComponent <GroupMemberFrame>().Show(friendItem);

                if (groupMemberIDs.Contains(friendItem.userId))
                {
                    go.GetComponent <GroupMemberFrame>().SetToggleInactive();
                }
            }
            _gridSelectMember.GetComponent <RectTransform>().sizeDelta = new Vector2(
                GlobalVars.DEFAULT_SCREEN_WIDTH,
                GlobalContacts.GetInstance().Count *GROUP_MEMBER_FRAME_HEIGHT);

            _selectUserIdSet.Clear();
            RefreshGroupMember();
        }
Example #5
0
        public virtual void Show(ChatLog chatLog)
        {
            _chatLog = chatLog;

            // Set UserItem //

            UserItem userItem = GlobalContacts.GetInstance().GetUserItemById(chatLog.chatID);

            if (userItem != null && chatLog.targetType == ChatDataItem.TargetType.INDIVIDUAL)
            {
                if (_imageHead)
                {
                    UIManager.GetInstance().SetImage(_imageHead, EAtlasName.Head, "00" + userItem.headIndex);
                }

                if (_labelUserName)
                {
                    _labelUserName.text = userItem.userName;
                }
            }


            // Set ChatItem //
            if (_labelLastChat)
            {
                _labelLastChat.text = "";
                ChatDataItem lastChat = GlobalChat.GetInstance().GetLastChat(chatLog.chatID);
                if (lastChat != null)
                {
                    if (lastChat.chatType == ChatDataItem.ChatType.TEXT)
                    {
                        _labelLastChat.text = lastChat.chatBody;
                    }
                    else if (lastChat.chatType == ChatDataItem.ChatType.IMAGE)
                    {
                        _labelLastChat.text = "[表情]";
                    }
                }
            }

            if (_labelDate)
            {
                _labelDate.text = DateFormatTool.GetChatFrameTimeStr(_chatLog.date);
            }

            if (_imageUnRead)
            {
                int num = GlobalChat.GetInstance().GetUnReadNum(_chatLog.chatID);
                num = (num > 99) ? 99 : num;
                _imageUnRead.gameObject.SetActive(num != 0);
                _labelUnReadNum.text = num.ToString();
            }
        }
Example #6
0
        public override void OnEnter(object param)
        {
            Init(param);

            _guestUserItem = GlobalContacts.GetInstance().GetUserItemById(_chatLog.chatID);
            if (_guestUserItem != null)
            {
                if (_labelGuestUserName)
                {
                    _labelGuestUserName.text = _guestUserItem.userName;
                }
            }
        }
        private void RefreshGroupMember()
        {
            UIManager.GetInstance().RefreshChildren(_gridMember.gameObject,
                                                    EUIType.GroupMemberHeadIcon,
                                                    _selectUserIdSet.Count,
                                                    GROUP_MEMBER_ICON_WIDTH, false);;

            List <string> userIdList = new List <string>(_selectUserIdSet);

            for (int i = 0; i < userIdList.Count; i++)
            {
                _gridMember.transform.GetChild(i).GetComponent <GroupMemberFrame>().
                Show(GlobalContacts.GetInstance().GetUserItemById(userIdList[i]));
            }
        }
Example #8
0
        public void OnClearAll(string[] args)
        {
            PlayerPrefs.DeleteKey(GlobalVars.PREF_USER_ID);
            PlayerPrefs.DeleteKey(GlobalVars.PREF_USER_PASSWORD);

            GlobalChat.GetInstance().ClearLogDict();
            GlobalContacts.GetInstance().ClearFriendDict();
            GlobalGroup.GetInstance().ClearGroupDict();

            DirectoryInfo dirInfo = new DirectoryInfo(Application.persistentDataPath);

            foreach (var item in dirInfo.GetDirectories())
            {
                item.Delete(true);
            }
        }
        public UserItem GetGroupMember(string userID)
        {
            if (_groupMemberDict.ContainsKey(userID))
            {
                return(_groupMemberDict[userID]);
            }
            else
            {
                UserItem userItem = GlobalContacts.GetInstance().GetUserItemById(userID);

                if (userID == GlobalUser.GetInstance().UserId)
                {
                    userItem = GlobalUser.GetInstance().Self;
                }

                if (userItem == null)
                {
                    _waitQueryMemberSet.Add(userID);
                }

                return(userItem);
            }
        }