1
0
mirror of https://github.com/etesync/android synced 2025-01-11 16:21:10 +00:00

Check for null values in StructuredPostal.TYPE (should fix #549)

This commit is contained in:
Ricki Hirner 2015-06-14 12:00:34 +02:00
parent 18c08bc9dd
commit 534953fe4c

View File

@ -142,7 +142,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
String where; String where;
if (remoteResources.length != 0) { if (remoteResources.length != 0) {
List<String> sqlFileNames = new LinkedList<String>(); List<String> sqlFileNames = new LinkedList<>();
for (Resource res : remoteResources) for (Resource res : remoteResources)
sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName())); sqlFileNames.add(DatabaseUtils.sqlEscapeString(res.getName()));
where = entryColumnRemoteName() + " NOT IN (" + StringUtils.join(sqlFileNames, ",") + ")"; where = entryColumnRemoteName() + " NOT IN (" + StringUtils.join(sqlFileNames, ",") + ")";
@ -472,19 +472,20 @@ public class LocalAddressBook extends LocalCollection<Contact> {
protected void populatePostalAddress(Contact c, ContentValues row) { protected void populatePostalAddress(Contact c, ContentValues row) {
Address address = new Address(); Address address = new Address();
address.setLabel(row.getAsString(StructuredPostal.FORMATTED_ADDRESS)); address.setLabel(row.getAsString(StructuredPostal.FORMATTED_ADDRESS));
switch (row.getAsInteger(StructuredPostal.TYPE)) { if (row.containsKey(StructuredPostal.TYPE))
case StructuredPostal.TYPE_HOME: switch (row.getAsInteger(StructuredPostal.TYPE)) {
address.addType(AddressType.HOME); case StructuredPostal.TYPE_HOME:
break; address.addType(AddressType.HOME);
case StructuredPostal.TYPE_WORK: break;
address.addType(AddressType.WORK); case StructuredPostal.TYPE_WORK:
break; address.addType(AddressType.WORK);
case StructuredPostal.TYPE_CUSTOM: break;
String customType = row.getAsString(StructuredPostal.LABEL); case StructuredPostal.TYPE_CUSTOM:
if (StringUtils.isNotEmpty(customType)) String customType = row.getAsString(StructuredPostal.LABEL);
address.addType(AddressType.get(labelToXName(customType))); if (StringUtils.isNotEmpty(customType))
break; address.addType(AddressType.get(labelToXName(customType)));
} break;
}
address.setStreetAddress(row.getAsString(StructuredPostal.STREET)); address.setStreetAddress(row.getAsString(StructuredPostal.STREET));
address.setPoBox(row.getAsString(StructuredPostal.POBOX)); address.setPoBox(row.getAsString(StructuredPostal.POBOX));
address.setExtendedAddress(row.getAsString(StructuredPostal.NEIGHBORHOOD)); address.setExtendedAddress(row.getAsString(StructuredPostal.NEIGHBORHOOD));
@ -965,7 +966,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
String lineStreet = StringUtils.join(new String[] { address.getStreetAddress(), address.getPoBox(), address.getExtendedAddress() }, " "), String lineStreet = StringUtils.join(new String[] { address.getStreetAddress(), address.getPoBox(), address.getExtendedAddress() }, " "),
lineLocality = StringUtils.join(new String[] { address.getPostalCode(), address.getLocality() }, " "); lineLocality = StringUtils.join(new String[] { address.getPostalCode(), address.getLocality() }, " ");
List<String> lines = new LinkedList<String>(); List<String> lines = new LinkedList<>();
if (lineStreet != null) if (lineStreet != null)
lines.add(lineStreet); lines.add(lineStreet);
if (address.getRegion() != null && !address.getRegion().isEmpty()) if (address.getRegion() != null && !address.getRegion().isEmpty())
@ -1031,7 +1032,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
} }
protected Builder buildRelated(Builder builder, RelatedType type, String name) { protected Builder buildRelated(Builder builder, RelatedType type, String name) {
int typeCode = 0; int typeCode;
String typeLabel = null; String typeLabel = null;
if (type == RelatedType.CHILD) if (type == RelatedType.CHILD)
typeCode = Relation.TYPE_CHILD; typeCode = Relation.TYPE_CHILD;