Exemple #1
0
 /// <summary>
 /// Set's avatar for a user in the list.
 /// </summary>
 /// <param name="friend">username of the user we want to set avatar to</param>
 /// <param name="avatar">avatar to set</param>
 public void SetAvatar(string friend, Texture avatar)
 {
     foreach (FriendListItem.FriendItemData friendData in Data)
     {
         if (friendData.Name.Equals(friend))
         {
             friendData.Avatar = avatar;
             break;
         }
     }
     RecyclableList.NotifyDataChanged();
 }
Exemple #2
0
 public void IncrementUnreadCount(string friend)
 {
     foreach (FriendListItem.FriendItemData friendData in Data)
     {
         if (friendData.Name.Equals(friend))
         {
             friendData.UnreadMessages++;
             break;
         }
     }
     RecyclableList.NotifyDataChanged();
 }
Exemple #3
0
        /// <summary>
        /// Change status of a user in the list.
        /// </summary>
        /// <param name="friend">username of the user we want to change status</param>
        /// <param name="newStatus">new status of the user</param>
        public void ChangeStatus(string friend, Status newStatus)
        {
            int index = Data.FindIndex(data => data.Name == friend);

            if (index < 0)
            {
                return;
            }
            var changedData = Data[index];
            var oldStatus   = changedData.Status;

            changedData.Status = newStatus;
            if (oldStatus != Status.Offline && newStatus == Status.Offline)
            {
                // if friend went offline we roll every online friend that's after them
                // in the list 1 place forward until we reach offline friend or end of the list
                for (int i = index; i < Data.Count; i++)
                {
                    if (i + 1 == Data.Count || Data[i + 1].Status == Status.Offline)
                    {
                        Data[i] = changedData;
                        break;
                    }
                    Data[i] = Data[i + 1];
                }
            }
            else if (oldStatus == Status.Offline && newStatus != Status.Offline)
            {
                // if user came online we roll every offline friend in front of him 1 place behind
                // until we reach first online friend of beginning of the list
                for (int i = index; i >= 0; i--)
                {
                    if (i == 0 || Data[i - 1].Status != Status.Offline)
                    {
                        Data[i] = changedData;
                        break;
                    }
                    Data[i] = Data[i - 1];
                }
            }
            RecyclableList.NotifyDataChanged();
        }