From d4cd1c4b58f9831603d3e77b59d5b421f903a0f2 Mon Sep 17 00:00:00 2001 From: srowen Date: Thu, 19 Jan 2012 12:52:20 +0000 Subject: [PATCH] Avoid an NPE in Arrays.asList git-svn-id: https://zxing.googlecode.com/svn/trunk@2121 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../zxing/client/android/encode/QRCodeEncoder.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java b/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java index 093b82b5f..71f2336d8 100755 --- a/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java +++ b/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java @@ -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 toIterable(String[] values) { + return values == null ? null : Arrays.asList(values); + } + Bitmap encodeAsBitmap() throws WriterException { Map hints = null; String encoding = guessAppropriateEncoding(contents);