/// <summary>
        /// Build the UI from the given contact. If the contact is new,
        /// immediately go to edit mode. Otherwise, go to view mode.
        /// Called by ContactsExample.
        /// </summary>
        /// <param name="contact">Contact to load</param>
        public void Populate(MLContacts.Contact contact)
        {
            _contact = contact;

            if (string.IsNullOrEmpty(contact.ID))
            {
                _contact.Name = "<i>Name</i>";
                HandleBeginEdit();
            }
            else
            {
                IsEditing = false;
                UpdateHeaderButtons();
                Refresh();
            }
        }
        /// <summary>
        /// Rebuilds the displayed list. Called by ContactsExample.
        /// </summary>
        /// <param name="contacts">List of contacts to display</param>
        public void PopulateList(List <MLContacts.Contact> contacts)
        {
            DestroyListItems();

            for (int i = 0; i < contacts.Count; ++i)
            {
                MLContacts.Contact contact       = contacts[i];
                GameObject         contactItemGO = Instantiate(_contactItem.gameObject, transform);
                contactItemGO.transform.localPosition = new Vector3(-0.25f, 0.04f - (0.03f * i), 0);

                ContactItemVisualizer contactItem = contactItemGO.GetComponent <ContactItemVisualizer>();
                contactItem.ListPage    = this;
                contactItem.ID          = contact.ID;
                contactItem.ContactName = contact.Name;

                _contactGOList.Add(contactItemGO);
            }
        }
Exemple #3
0
        /// <summary>
        /// Adds a new contact or updates an existing contact.
        /// Called by ContactPageVisualizer.
        /// </summary>
        /// <param name="contact">The new contact to save.</param>
        public MLResult SaveContact(MLContacts.Contact contact)
        {
            ulong    requestHandle = 0;
            MLResult result;

            if (!string.IsNullOrEmpty(contact.ID))
            {
                Debug.LogFormat("Updating existing contact with id = {0}", contact.ID);
                result = MLContacts.UpdateContact(contact, out requestHandle);
            }
            else
            {
                Debug.LogFormat("Saving new contact with name = {0}", contact.Name);
                result = MLContacts.AddContact(contact, out requestHandle);
            }

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed to save contact. Reason: {0}", result);
            }

            return(result);
        }