Skip to content

Commit

Permalink
Import fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yassinsameh committed Jul 14, 2024
1 parent 51e87b0 commit 984ed6c
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import android.util.Log
import java.io.FileNotFoundException
import java.io.InputStream
import java.io.OutputStream
import java.io.IOException
import co.quis.flutter_contacts.properties.Account as PAccount
import co.quis.flutter_contacts.properties.Address as PAddress
import co.quis.flutter_contacts.properties.Email as PEmail
Expand Down Expand Up @@ -1167,20 +1168,20 @@ class FlutterContacts {
try {
fd = resolver.openAssetFileDescriptor(photoUri, "rw")
if (fd != null) {
FileOutputStream(fd.fileDescriptor).use { fos ->
fos.write(photo)
fos.flush() // Ensure all data is written
val os: OutputStream = fd.createOutputStream()
os.use { it ->
it.write(photo)
}
} else {
Log.e(IMAGE_HANDLING_ERROR, "Failed to open AssetFileDescriptor for photoUri: $photoUri")
Log.e("IMAGE_HANDLING_ERROR", "Failed to open AssetFileDescriptor for photoUri: $photoUri")
}
} catch (e: IOException) {
Log.e(TAG, "Error writing photo", e)
Log.e("IMAGE_HANDLING_ERROR", "Error writing photo", e)
} finally {
try {
fd?.close()
} catch (e: IOException) {
Log.e(IMAGE_HANDLING_ERROR, "Error closing AssetFileDescriptor", e)
Log.e("IMAGE_HANDLING_ERROR", "Error closing AssetFileDescriptor", e)
}
}
}
Expand Down

0 comments on commit 984ed6c

Please sign in to comment.