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) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
View view = null;
|
View view = null;
|
||||||
LinphoneContact contact = null;
|
LinphoneContact contact = (LinphoneContact) getItem(position);
|
||||||
do {
|
if (contact == null) return null;
|
||||||
contact = (LinphoneContact) getItem(position);
|
|
||||||
} while (contact == null);
|
|
||||||
|
|
||||||
if (convertView != null) {
|
if (convertView != null) {
|
||||||
view = convertView;
|
view = convertView;
|
||||||
|
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
|
@ -245,6 +246,7 @@ public class ContactsManager extends ContentObserver {
|
||||||
for (LinphoneContact contact : contacts) {
|
for (LinphoneContact contact : contacts) {
|
||||||
contact.refresh();
|
contact.refresh();
|
||||||
}
|
}
|
||||||
|
Collections.sort(contacts);
|
||||||
|
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
@ -39,7 +40,7 @@ import android.net.Uri;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.provider.ContactsContract.CommonDataKinds;
|
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();
|
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) {
|
private Uri getContactPictureUri(String id) {
|
||||||
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(id));
|
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(id));
|
||||||
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
|
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
|
||||||
|
|
Loading…
Reference in a new issue