From 76a1d2c3d64cddd5234e5bf4f2aa11655d5c1410 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 29 Apr 2020 21:27:47 +0200 Subject: [PATCH] convert contact photo from uri to bytearray directly, without creating a bitmap --- .../simplemobiletools/contacts/pro/helpers/ContactsHelper.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt index 97b8d7f3..0643b4a8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt @@ -1303,10 +1303,7 @@ class ContactsHelper(val context: Context) { var fullSizePhotoData: ByteArray? = null if (contact.photoUri.isNotEmpty()) { val photoUri = Uri.parse(contact.photoUri) - val bitmap = MediaStore.Images.Media.getBitmap(context.contentResolver, photoUri) - - fullSizePhotoData = bitmap.getByteArray() - bitmap.recycle() + fullSizePhotoData = context.contentResolver.openInputStream(photoUri)?.readBytes() } val results = context.contentResolver.applyBatch(AUTHORITY, operations)