Fixed crash when contact doesn't have a name

This commit is contained in:
Sylvain Berfini 2016-04-29 10:06:03 +02:00
parent 2bb0e3bdbb
commit a3ad1105e2
2 changed files with 20 additions and 12 deletions

View file

@ -431,7 +431,11 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
String prevLetter = null;
for (int i = 0; i < contacts.size(); i++) {
LinphoneContact contact = contacts.get(i);
String firstLetter = contact.getFullName().substring(0, 1).toUpperCase(Locale.getDefault());
String fullName = contact.getFullName();
if (fullName == null || fullName.isEmpty()) {
continue;
}
String firstLetter = fullName.substring(0, 1).toUpperCase(Locale.getDefault());
if (!firstLetter.equals(prevLetter)) {
prevLetter = firstLetter;
map.put(firstLetter, i);
@ -561,7 +565,11 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
return 0;
}
LinphoneContact contact = contacts.get(position);
String letter = contact.getFullName().substring(0, 1);
String fullName = contact.getFullName();
if (fullName == null || fullName.isEmpty()) {
return 0;
}
String letter = fullName.substring(0, 1);
return sectionsList.indexOf(letter);
}
}

View file

@ -368,16 +368,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
addresses = new ArrayList<LinphoneNumberOrAddress>();
hasSipAddress = false;
if (!isAndroidContact() && isLinphoneFriend()) {
fullName = friend.getName();
thumbnailUri = null;
photoUri = null;
LinphoneAddress addr = friend.getAddress();
if (addr != null) {
addresses.add(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
hasSipAddress = true;
}
} else if (isAndroidContact()) {
if (isAndroidContact()) {
String id = getAndroidId();
getContactNames(id);
setThumbnailUri(getContactPictureUri(id));
@ -416,6 +407,15 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
}
}
}
} else if (isLinphoneFriend()) {
fullName = friend.getName();
thumbnailUri = null;
photoUri = null;
LinphoneAddress addr = friend.getAddress();
if (addr != null) {
addresses.add(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
hasSipAddress = true;
}
}
}