|
@@ -71,6 +71,8 @@ import org.greenrobot.eventbus.ThreadMode;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
@@ -150,6 +152,21 @@ public class ContactListFragment extends FileFragment {
|
|
|
} else {
|
|
|
File file = new File(ocFile.getStoragePath());
|
|
|
vCards.addAll(Ezvcard.parse(file).all());
|
|
|
+ Collections.sort(vCards, new Comparator<VCard>() {
|
|
|
+ @Override
|
|
|
+ public int compare(VCard o1, VCard o2) {
|
|
|
+ if(o1.getFormattedName()!=null && o2.getFormattedName()!=null) {
|
|
|
+ return o1.getFormattedName().getValue().compareTo(o2.getFormattedName().getValue());
|
|
|
+ }else{
|
|
|
+ if(o1.getFormattedName()==null){
|
|
|
+ return 1; // Send the contact to the end of the list
|
|
|
+ }else{
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
Log_OC.e(TAG, "Error processing contacts file!", e);
|