Avoid an NPE in Arrays.asList

git-svn-id: https://zxing.googlecode.com/svn/trunk@2121 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-01-19 12:52:20 +00:00
parent 035320bd2f
commit d4cd1c4b58

View file

@ -282,11 +282,11 @@ final class QRCodeEncoder {
private void encodeQRCodeContents(AddressBookParsedResult contact) {
ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
String[] encoded = encoder.encode(Arrays.asList(contact.getNames()),
String[] encoded = encoder.encode(toIterable(contact.getNames()),
contact.getOrg(),
Arrays.asList(contact.getAddresses()),
Arrays.asList(contact.getPhoneNumbers()),
Arrays.asList(contact.getEmails()),
toIterable(contact.getAddresses()),
toIterable(contact.getPhoneNumbers()),
toIterable(contact.getEmails()),
contact.getURL(),
null);
// Make sure we've encoded at least one field.
@ -297,6 +297,10 @@ final class QRCodeEncoder {
}
}
private static Iterable<String> toIterable(String[] values) {
return values == null ? null : Arrays.asList(values);
}
Bitmap encodeAsBitmap() throws WriterException {
Map<EncodeHintType,Object> hints = null;
String encoding = guessAppropriateEncoding(contents);