EasyImage
EasyImage copied to clipboard
Images taken from camera do not call onMediaFilesPicked if camera was selected from chooser
I think this is a bug, the method onMediaFilesPicked will be called only if you take a picture from openCameraForImage. If you pick Camera from openChooser the method is skipped.
Error message:
D/EasyImage: File returned from chooser Existing picture returned from local storage W/System.err: kotlin.KotlinNullPointerException at pl.aprilapps.easyphotopicker.EasyImage.onPickedExistingPicturesFromLocalStorage(EasyImage.kt:171) at pl.aprilapps.easyphotopicker.EasyImage.onPickedExistingPictures(EasyImage.kt:201) W/System.err: at pl.aprilapps.easyphotopicker.EasyImage.onFileReturnedFromChooser(EasyImage.kt:249) at pl.aprilapps.easyphotopicker.EasyImage.handleActivityResult(EasyImage.kt:156)
Same here with Android 10
exact same problem on emulator android 8.0.0 (api 26)
same problem on android 10
The problem still exists. Any idea?
I was able to mitigate it with the following
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
activity?.let {
val dataIntent = fixDataIntentForEasyImage(data)
easyImage.handleActivityResult(requestCode, resultCode, dataIntent, it, callback)
...
}
}
private fun fixDataIntentForEasyImage(dataIntent: Intent?): Intent? {
if (dataIntent == null) {
return null
}
if (dataIntent.dataString.isNullOrEmpty()) {
return null
}
return dataIntent
}
The issue comes from the fact that EasyImage relies on the fact that the result data intent is null if the image came from the camera. This is not true for all cameras though. Some return an Intent without data.
The same issue here. Should I fallback to 2.x?
falling back does not work for me :c
Still, this issue occurred with android version 10 (Redmi devices). Please check and fix this issue. Currently, I have used dependency "implementation 'com.github.jkwiecien:EasyImage:3.2.0'".
Functionality used by me.
val dataIntent = fixDataIntentForEasyImage(data)
easyImage.handleActivityResult(
requestCode,
resultCode,
dataIntent,
mContext as AppCompatActivity,
object : DefaultCallback() {
override fun onMediaFilesPicked(
imageFiles: Array<MediaFile>,
source: MediaSource
) {
Log.e("imageFiles", "" + imageFiles.size)
CropImage.activity(Uri.fromFile(imageFiles[0].file))
.setAllowFlipping(false)
.start(mContext as AppCompatActivity)
}
})
====================================
private fun fixDataIntentForEasyImage(dataIntent: Intent?): Intent? { if (dataIntent == null) { return null } if (dataIntent.dataString.isNullOrEmpty()) { return null } return dataIntent }