public void GetEmailList(EmailListFragment fragment,ViewGroup rootview) { nn_activity.RunOnUiThread(()=>{ fragment.AddSpinner(rootview,"Loading"); }); var book = new Xamarin.Contacts.AddressBook (nn_activity); book.ToList ().ForEach (p=>{ string name = ""; if (p.FirstName != null) { name += p.FirstName+" "; } if (p.LastName != null) { name += p.LastName; } List<Email> emaillist = p.Emails.ToList (); if (emaillist.Count > 0) { foreach(var email in emaillist){ ContactInfo info = new ContactInfo (name,email.Address); contactinfolist.Add (info); break; } } } ); nn_activity.RunOnUiThread(()=>{ fragment.RemoveSpinner(rootview); fragment.adapter.notifycontactlistdatachange(); }); }
public void GetEmailList(EmailListFragment fragment,ViewGroup rootview) { nn_activity.RunOnUiThread(()=>{ fragment.AddSpinner(rootview,"Loading"); }); var book = new Xamarin.Contacts.AddressBook (nn_activity); List<Contact> list = book.ToList (); list.Sort ( delegate(Contact x, Contact y) { if (String.IsNullOrEmpty(x.FirstName) && String.IsNullOrEmpty(y.FirstName)) return 0; else if (x.FirstName == null) return -1; else if (y.FirstName == null) return 1; else return x.FirstName.CompareTo(y.FirstName); }); list.ForEach (p=>{ string name = ""; if (p.FirstName != null) { name += p.FirstName+" "; } if (p.LastName != null) { name += p.LastName; } List<Email> emaillist = p.Emails.ToList (); if (emaillist.Count > 0) { foreach(var email in emaillist){ ContactInfo info = new ContactInfo (name,email.Address); contactinfolist.Add (info); break; } } }); nn_activity.RunOnUiThread(()=>{ fragment.RemoveSpinner(rootview); fragment.adapter.notifycontactlistdatachange(); }); }