alejandro 8 жил өмнө
parent
commit
f94169a458

+ 17 - 0
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java

@@ -71,6 +71,8 @@ import org.greenrobot.eventbus.ThreadMode;
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Set;
 import java.util.Set;
@@ -150,6 +152,21 @@ public class ContactListFragment extends FileFragment {
             } else {
             } else {
                 File file = new File(ocFile.getStoragePath());
                 File file = new File(ocFile.getStoragePath());
                 vCards.addAll(Ezvcard.parse(file).all());
                 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) {
         } catch (IOException e) {
             Log_OC.e(TAG, "Error processing contacts file!", e);
             Log_OC.e(TAG, "Error processing contacts file!", e);