2

I am developing an application that needs to list all contacts in the phone's contacts list. Each cell needs to have the name of the contact and the corresponding photo (primaryPhoto). I can do this, by fetching contactDetails for each contact. However, if the contacts list has a huge number of elements, this process is too slow. To handle this problem, I am not fetching the contact details and I am using the partial contacts retreived by

contacts = m_contactService->contacts(filter);

The only problem is that this list doesn't contain any photo! And I need the primaryPhoto available.

Is there a way to get the primaryPhoto from a partialContact without the need to fecth all contact details?

Thanks for your help

1 Answers1

1

Implement the following after you get the list of contacts from this returned from the search filter

note: this is not pure C++, do not use this verbatim!

foreach contact in contacts
    m_CPhoto = contact->primaryPhoto(); //returns the ContactPhoto id
    // if necessary...
    m_cPhotoList << m_CPhoto; // you can do this since this would be a list of ids

// to display the actual photo in your list view
m_CPhoto->smallPhoto();
// I only use 'small' since this is a list view; you may use 'original' or 'large'
Igbanam
  • 5,904
  • 5
  • 44
  • 68
  • 1
    Hi thanks for your answer! The only problem is that the partial contacts doesn't contain the list of photos! To get them, I need to fetch the contact details, and that is taking me much time! I am trying to find a solution where I can send the partial list to the view and then, in background, fetch the photos and send them to list view! – Filipe Figueiredo Jan 24 '14 at 14:23
  • in this case, @FilipeFigueiredo, you can fork off a thread to do the background work. I have not attempted this but parallelization theoretically helps – Igbanam Jan 31 '14 at 05:01
  • 1
    that's a nice ideia, I will try that. Thanks – Filipe Figueiredo Feb 01 '14 at 19:50