diff options
author | Alan Young <consult.awy@gmail.com> | 2015-07-06 08:14:13 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2015-08-13 08:05:42 (GMT) |
commit | 9bf162922691c1f45813da6a21f2e274bfad3114 (patch) | |
tree | 2d7c49abc72ede17701c3300140718b1c3e81bcc /src/com/isode/stroke/vcards | |
parent | af3bb03053b9d83f4d38b31d66b292792206a327 (diff) | |
download | stroke-9bf162922691c1f45813da6a21f2e274bfad3114.zip stroke-9bf162922691c1f45813da6a21f2e274bfad3114.tar.bz2 |
VCard.getPhoto() to return null for absent photo.
Most of the time when VCard.getPhoto() is called it is only used to
determine presence or absence of a photo. Thus, it makes no sense to
allocate an empty ByteArray() just for this purpose. Return null
instead, if absent.
Change-Id: I3bae02ffbece5589c74c950bbb4c0db6c0376c76
Diffstat (limited to 'src/com/isode/stroke/vcards')
-rw-r--r-- | src/com/isode/stroke/vcards/VCardStorage.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/com/isode/stroke/vcards/VCardStorage.java b/src/com/isode/stroke/vcards/VCardStorage.java index cb732ea..5ac095c 100644 --- a/src/com/isode/stroke/vcards/VCardStorage.java +++ b/src/com/isode/stroke/vcards/VCardStorage.java @@ -4,6 +4,7 @@ */ package com.isode.stroke.vcards; +import com.isode.stroke.base.ByteArray; import com.isode.stroke.crypto.CryptoProvider; import com.isode.stroke.elements.VCard; import com.isode.stroke.jid.JID; @@ -24,12 +25,13 @@ public abstract class VCardStorage { public void delete() {}; public String getPhotoHash(final JID jid) { - VCard vCard = getVCard(jid); - if (vCard != null && vCard.getPhoto().getSize() != 0) { - return Hexify.hexify(crypto.getSHA1Hash(vCard.getPhoto())); - } - else { - return ""; + final VCard vCard = getVCard(jid); + if (vCard != null) { + final ByteArray photo = vCard.getPhoto(); + if (photo != null) { + return Hexify.hexify(crypto.getSHA1Hash(photo)); + } } + return ""; } } |