# HG changeset patch # User marseille@marseille-desktop # Date 1245318780 -7200 # Node ID f879726d62955823de09958c1e7b901c86ac8f5d # Parent 65369afd96d35b0fada2409958ae8cd715cbd5d5 Contact List : + Ajout d'un tri par Name + Ajout d'un tri par Status et Name diff -r 65369afd96d3 -r f879726d6295 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Thu Jun 18 11:30:23 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Thu Jun 18 11:53:00 2009 +0200 @@ -104,18 +104,32 @@ unbindService(mServConn); } - class ComparatorContactListByStatus implements Comparator { + class ComparatorContactListByName implements Comparator { + @Override public int compare(T c1, T c2) { - if (((Contact) c1).getStatus() < ((Contact) c2).getStatus()) + return ((Contact) c1).getName().compareToIgnoreCase(((Contact) c2).getName()); + } + + } + + class ComparatorContactListByStatusAndName implements Comparator { + + @Override + public int compare(T c1, T c2) { + if (((Contact) c1).getStatus() < ((Contact) c2).getStatus()) { return 1; - return -1; + } else if (((Contact) c1).getStatus() > ((Contact) c2).getStatus()) { + return -1; + } else + return ((Contact) c1).getName().compareToIgnoreCase(((Contact) c2).getName()); } } private void buildContactList(List listContact) { - Collections.sort(listContact, new ComparatorContactListByStatus()); + Collections.sort(listContact, new ComparatorContactListByStatusAndName()); + // Collections.sort(listContact, new ComparatorContactListByName()); mListContact = listContact; for (Contact contact : listContact) { for (String group : contact.getGroups()) {