Example #1
0
 /// <summary>
 /// Copy achievement data from another contact object to this contact
 /// </summary>
 /// <param name="contact">Contact to copy achievement data</param>
 public void CopyAchievementDetails(ContactViewModel contact)
 {
     this.StorageAmount           = contact.StorageAmount;
     this.TransferAmount          = contact.TransferAmount;
     this.ReferralBonusExpireDate = contact.ReferralBonusExpireDate;
 }
Example #2
0
        protected void OnContactUpdated(object sender, MUser user)
        {
            if (user == null)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "'MUser' is NULL");
                return;
            }

            ContactViewModel existingContact = null;

            try
            {
                existingContact = (ContactViewModel)this.ItemCollection.Items.FirstOrDefault(
                    contact => contact.Handle.Equals(user.getHandle()));
            }
            catch (Exception e)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Error checking if the contact exists", e);
                return;
            }

            // If the contact exists in the contact list
            if (existingContact != null)
            {
                //If the contact is no longer a contact(REMOVE CONTACT SCENARIO)
                if (!existingContact.Visibility.Equals(user.getVisibility()) &&
                    !(user.getVisibility().Equals(MUserVisibility.VISIBILITY_VISIBLE)))
                {
                    OnUiThread(() => this.ItemCollection.Items.Remove(existingContact));
                }
                // If the contact has been changed (UPDATE CONTACT SCENARIO) and is not an own change
                else if (!Convert.ToBoolean(user.isOwnChange()))
                {
                    if (user.hasChanged((int)MUserChangeType.CHANGE_TYPE_AVATAR) &&
                        !string.IsNullOrWhiteSpace(existingContact.AvatarPath))
                    {
                        existingContact.GetContactAvatar();
                    }

                    if (user.hasChanged((int)MUserChangeType.CHANGE_TYPE_EMAIL))
                    {
                        OnUiThread(() => existingContact.Email = user.getEmail());
                    }

                    if (user.hasChanged((int)MUserChangeType.CHANGE_TYPE_FIRSTNAME))
                    {
                        existingContact.GetContactFirstname();
                    }

                    if (user.hasChanged((int)MUserChangeType.CHANGE_TYPE_LASTNAME))
                    {
                        existingContact.GetContactLastname();
                    }
                }
            }
            // If is a new contact (ADD CONTACT SCENARIO - REQUEST ACCEPTED)
            else if (user.getVisibility().Equals(MUserVisibility.VISIBILITY_VISIBLE))
            {
                var megaContact = new ContactViewModel(user, this);

                OnUiThread(() => this.ItemCollection.Items.Add(megaContact));

                megaContact.GetContactFirstname();
                megaContact.GetContactLastname();
                megaContact.GetContactAvatarColor();
                megaContact.GetContactAvatar();
            }
        }