Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitfireAT/vcard4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt')
-rw-r--r--src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt b/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt
index 01d58c1..de17724 100644
--- a/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt
+++ b/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt
@@ -22,8 +22,7 @@ class PhotoHandler(val provider: ContentProviderClient?): DataRowHandler() {
override fun handle(values: ContentValues, contact: Contact) {
super.handle(values, contact)
- val photoId = values.getAsLong(Photo.PHOTO_FILE_ID)
- if (photoId != null) {
+ values.getAsLong(Photo.PHOTO_FILE_ID)?.let { photoId ->
val photoUri = ContentUris.withAppendedId(ContactsContract.DisplayPhoto.CONTENT_URI, photoId)
try {
provider?.openAssetFile(photoUri, "r")?.let { file ->
@@ -34,7 +33,9 @@ class PhotoHandler(val provider: ContentProviderClient?): DataRowHandler() {
} catch(e: IOException) {
Constants.log.log(Level.WARNING, "Couldn't read local contact photo file", e)
}
- } else
+ }
+
+ if (contact.photo == null)
contact.photo = values.getAsByteArray(Photo.PHOTO)
}