private static int CompareBasedOnContactListSizeImpl(IContactList contactListA, IContactList contactListB)
        {
            int countA = contactListA.Count;
            int countB = contactListB.Count;

            if (countA == 0)
            {
                if (countB == 1)
                {
                    // A is unknown sender, B is single known partner

                    return 1;
                }
                else if (countB > 1)
                {
                    // A is unknown sender, B is group chat

                    return -1;
                }
            }
            else if ((countA > 1) && (countB <= 1))
            {
                // A is group chat, B is single (known/unkonwn) partner

                return 1;
            }

            return 0;
        }
Esempio n. 2
0
        public ContatoViewModel()
        {
            IContactList contactList = DependencyService.Get <IContactList>();

            try {
                Contatos = contactList.GetAllContacts();
            } catch {
                App.Current.MainPage.DisplayAlert("Não foi possível carregar os contatos ",
                                                  "Verifique as permissões do aplicativo", "Ok");
            }

            EditCMD = new OnEditCMD(this);
            CallCMD = new OnCallCMD(this);
        }
Esempio n. 3
0
        private static int CompareContactListsAlphabetically(IContactList contactListA, IContactList contactListB)
        {
            int comparisons = Math.Min(contactListA.Count, contactListB.Count);

            for (int contactIndex = 0; contactIndex < comparisons; contactIndex++)
            {
                int contactCompare = ContactComparer.CompareAlphabetically(contactListA[contactIndex], contactListB[contactIndex]);
                if (contactCompare != 0)
                {
                    return(contactCompare);
                }
            }

            return(contactListA.Count - contactListB.Count);
        }
        private static int CompareBasedOnContactListSize(IContactList contactListA, IContactList contactListB)
        {
            int sizeCompare = CompareBasedOnContactListSizeImpl(contactListA, contactListB);
            if (sizeCompare != 0)
            {
                return sizeCompare;
            }
            sizeCompare = -1 * CompareBasedOnContactListSizeImpl(contactListB, contactListA);
            if (sizeCompare != 0)
            {
                return sizeCompare;
            }

            return 0;
        }
Esempio n. 5
0
        private static int CompareBasedOnContactListSize(IContactList contactListA, IContactList contactListB)
        {
            int sizeCompare = CompareBasedOnContactListSizeImpl(contactListA, contactListB);

            if (sizeCompare != 0)
            {
                return(sizeCompare);
            }
            sizeCompare = -1 * CompareBasedOnContactListSizeImpl(contactListB, contactListA);
            if (sizeCompare != 0)
            {
                return(sizeCompare);
            }

            return(0);
        }
Esempio n. 6
0
        private ContactList CoalesceContactLists(IContactList contactListA, IContactList contactListB)
        {
            Dictionary <long, IContactList> hashByContactId = new Dictionary <long, IContactList>();

            HashByContactId(hashByContactId, contactListA);
            HashByContactId(hashByContactId, contactListB);

            ContactList mergedContacts = new ContactList();

            foreach (IContactList contactListById in hashByContactId.Values)
            {
                IContact contactMerged = contactListById[0];
                for (int contactIndex = 1; contactIndex < contactListById.Count; contactIndex++)
                {
                    IContact contactCurrent = contactListById[contactIndex];
                    contactMerged = new MergedContact(contactMerged, contactCurrent);
                }
                mergedContacts.Add(contactMerged);
            }

            return(mergedContacts);
        }
 public MockEmptyConversation(IEnumerable <IContact> contacts)
 {
     AssociatedContacts = new ContactList(contacts);
 }
Esempio n. 8
0
 public IActionResult AddContact([FromBody] IContactList contact)
 {
     this.contacts.Add(contact);
     return(CreatedAtRoute("GetSpecificItem", new { index = contacts.IndexOf(contact) }, contact));
 }
Esempio n. 9
0
 public bool Equals(IContactList otherContactList)
 {
     return Enumerable.SequenceEqual(_contacts, otherContactList);
 }
Esempio n. 10
0
        private static int CompareBasedOnContactListSizeImpl(IContactList contactListA, IContactList contactListB)
        {
            int countA = contactListA.Count;
            int countB = contactListB.Count;

            if (countA == 0)
            {
                if (countB == 1)
                {
                    // A is unknown sender, B is single known partner

                    return(1);
                }
                else if (countB > 1)
                {
                    // A is unknown sender, B is group chat

                    return(-1);
                }
            }
            else if ((countA > 1) && (countB <= 1))
            {
                // A is group chat, B is single (known/unkonwn) partner

                return(1);
            }

            return(0);
        }
Esempio n. 11
0
        private static int CompareContactListsAlphabetically(IContactList contactListA, IContactList contactListB)
        {
            int comparisons = Math.Min(contactListA.Count, contactListB.Count);

            for (int contactIndex = 0; contactIndex < comparisons; contactIndex++)
            {
                int contactCompare = ContactComparer.CompareAlphabetically(contactListA[contactIndex], contactListB[contactIndex]);
                if (contactCompare != 0)
                {
                    return contactCompare;
                }
            }

            return contactListA.Count - contactListB.Count;
        }
Esempio n. 12
0
 public ChatConversation(IEnumerable <IContact> assocaiatedContacts)
 {
     AssociatedContacts = new ContactList(assocaiatedContacts);
     AssociatedContacts.Sort(ContactComparer.CompareAlphabetically);
 }
Esempio n. 13
0
 private void HashByContactId(Dictionary <long, IContactList> hashByContactId, IContactList contactList)
 {
     foreach (IContact contact in contactList)
     {
         IContactList hashedContactList;
         if (hashByContactId.ContainsKey(contact.ContactId))
         {
             hashedContactList = hashByContactId[contact.ContactId];
             hashedContactList.Add(contact);
         }
         else
         {
             hashedContactList = new ContactList();
             hashedContactList.Add(contact);
             hashByContactId[contact.ContactId] = contactList;
         }
     }
 }
Esempio n. 14
0
 public bool Equals(IContactList otherContactList)
 {
     return(Enumerable.SequenceEqual(_contacts, otherContactList));
 }