Exemple #1
0
        private IEnumerator UpdatePageCoroutine(bool showContent, string groupToSelect)
        {
            yield return(StartCoroutine(FillGroups()));

            UpdateContentVisibility(showContent);

            if (!string.IsNullOrEmpty(groupToSelect))
            {
                groupsController.SelectGroup(groupToSelect);
            }
            else
            {
                groupsController.SelectDefault();
            }
        }
        public static void RefreshGroups(GroupsController groupsController, string selectedGroup = null)
        {
            if (groupsController == null)
            {
                return;
            }
            groupsController.RemoveAll();

            var friendsGroup = groupsController.AddGroup(USER_FRIENDS_GROUP).GetComponent <FriendGroup>();

            friendsGroup.SetUsersCount(UserFriends.Instance.Friends.Count);
            UserFriends.Instance.UserFriendsUpdatedEvent += () => friendsGroup.SetUsersCount(UserFriends.Instance.Friends.Count);

            var pendingGroup = groupsController.AddGroup(PENDING_USERS_GROUP).GetComponent <FriendGroup>();

            pendingGroup.SetUsersCount(UserFriends.Instance.Pending.Count);
            UserFriends.Instance.PendingUsersUpdatedEvent += () => pendingGroup.SetUsersCount(UserFriends.Instance.Pending.Count);

            var requestedGroup = groupsController.AddGroup(REQUESTED_USERS_GROUP).GetComponent <FriendGroup>();

            requestedGroup.SetUsersCount(UserFriends.Instance.Requested.Count);
            UserFriends.Instance.RequestedUsersUpdatedEvent += () => requestedGroup.SetUsersCount(UserFriends.Instance.Requested.Count);

            var blockedGroup = groupsController.AddGroup(BLOCKED_USERS_GROUP).GetComponent <FriendGroup>();

            blockedGroup.SetUsersCount(UserFriends.Instance.Blocked.Count);
            UserFriends.Instance.BlockedUsersUpdatedEvent += () => blockedGroup.SetUsersCount(UserFriends.Instance.Blocked.Count);

            var addFriendsGroup = groupsController.AddGroup(ADD_FRIENDS_GROUP).GetComponent <FriendGroup>();

            addFriendsGroup.enabled = false;

            if (string.IsNullOrEmpty(selectedGroup) && !string.IsNullOrEmpty(_selectedGroup))
            {
                selectedGroup = _selectedGroup;
            }
            _selectedGroup = selectedGroup;

            if (string.IsNullOrEmpty(_selectedGroup))
            {
                groupsController.SelectDefault();
            }
            else
            {
                groupsController.Groups.First(g => g.Name.Equals(_selectedGroup)).Select();
            }
        }