Пример #1
0
        /// <summary>
        /// Displays the items from the contact store in the contacts view.
        /// </summary>
        /// <param name="reader">Contact store reader</param>
        /// <param name="isGroup">
        /// Boolean to decide if to show the list in a group or a flat list
        /// Groups is shown by default and search
        /// Flast list is shown during search
        /// </param>
        private async Task DisplayContactsFromReaderAsync(ContactReader reader, bool isGroup)
        {
            contactItems.Clear();
            ContactBatch contactBatch = await reader.ReadBatchAsync();

            if (contactBatch.Contacts.Count == 0)
            {
                Debug.WriteLine("Contact store empty");
                ContactsStatusText = "We couldn't find any contacts.";
                ShowContactListStatusText();
                return;
            }

            while (contactBatch.Contacts.Count != 0)
            {
                //should batch add to avoid triggering callbacks
                foreach (Contact c in contactBatch.Contacts)
                {
                    ContactItem contactToAdd = new ContactItem(c.Id, c.DisplayName);
                    contactToAdd.SetImageAsync(c.Thumbnail);
                    contactItems.Add(contactToAdd);
                }
                contactBatch = await reader.ReadBatchAsync();
            }

            if (isGroup)
            {
                GroupsOfContacts = alphaGroupSorting(contactItems);
                ShowContactGroup();
            }
            else
            {
                ListOfContacts = contactItems;
                ShowContactList();
            }
            return;
        }