This should sort the contact list alphabetically
This commit is contained in:
parent
4e9446b608
commit
448355136b
3 changed files with 13 additions and 5 deletions
|
@ -457,10 +457,8 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
LinphoneContact contact = null;
|
||||
do {
|
||||
contact = (LinphoneContact) getItem(position);
|
||||
} while (contact == null);
|
||||
LinphoneContact contact = (LinphoneContact) getItem(position);
|
||||
if (contact == null) return null;
|
||||
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
|
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
package org.linphone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
|
@ -245,6 +246,7 @@ public class ContactsManager extends ContentObserver {
|
|||
for (LinphoneContact contact : contacts) {
|
||||
contact.refresh();
|
||||
}
|
||||
Collections.sort(contacts);
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
|
@ -39,7 +40,7 @@ import android.net.Uri;
|
|||
import android.provider.ContactsContract;
|
||||
import android.provider.ContactsContract.CommonDataKinds;
|
||||
|
||||
public class LinphoneContact implements Serializable {
|
||||
public class LinphoneContact implements Serializable, Comparable<LinphoneContact> {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -437,6 +438,13 @@ public class LinphoneContact implements Serializable {
|
|||
return createLinphoneFriend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LinphoneContact contact) {
|
||||
String firstLetter = getFullName().substring(0, 1).toUpperCase(Locale.getDefault());
|
||||
String contactfirstLetter = contact.getFullName().substring(0, 1).toUpperCase(Locale.getDefault());
|
||||
return firstLetter.compareTo(contactfirstLetter);
|
||||
}
|
||||
|
||||
private Uri getContactPictureUri(String id) {
|
||||
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(id));
|
||||
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
|
||||
|
|
Loading…
Reference in a new issue