nguyenhoanglam / ImagePicker

A customizable library for selecting images on the device.
Apache License 2.0
599 stars 156 forks source link

It's not loading the images after updating to 1.4.1 or 1.4.0 #122

Closed ma7moudAziz closed 4 years ago

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Thanks for this awesome library it is very useful for me, but recently after I update the module to the latest version it stops working, it opens but it keeps loading without showing the folders.

and here how I am implementing the ImagePicker:

`

ImagePicker.with(myFragment!!) .setToolbarColor("#3F51B5") .setStatusBarColor("#000000") .setToolbarTextColor("#FFFFFF") .setToolbarIconColor("#FFFFFF") .setProgressBarColor("#4CAF50") .setBackgroundColor("#FFFFFF") .setCameraOnly(false) .setMultipleMode(true) .setFolderMode(true) .setShowCamera(false) .setFolderTitle("Folder title") .setImageTitle("Image title") .setDoneTitle(getString(R.string.submitText)) .setLimitMessage(getString(R.string.reachImagesLimitErrorMessage)) .setMaxSize(100) .setAlwaysShowDoneButton(true) .start()

`

And to be noted I am using android and Kotlin v.1.3.72.

And thanks in advance, Regards.

nguyenhoanglam commented 4 years ago

@ma7moudAziz which Android version are you using? Please try with another version to check if it works. If it also not working, then let me know!

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam , Yes, it only not working on android 9, it's working just fine with android 7,8 and 10. Regards.

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Kindly assist me here, your assistance will be grateful and to be noted the new version 1.4.2 did not fix the issue. Regards.

odisoedim commented 4 years ago

same here please has this been fixed

nguyenhoanglam commented 4 years ago

@ma7moudAziz @robiky it sounds strange! I've just test on Samsung device (Android 9) and it works! Can you guys show me the app's log?

odisoedim commented 4 years ago

It's has no error log and it's android 10

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, thanks for your efforts but actually there is no errors showing in logs, but here are a part of the logs just after I click on the open camera function:

W/HiTouch_HiTouchSensor: depended package hiTouch does n't exist! 2020-06-08 09:56:28.566 4541-6034/com.infosysta.mobile.mfjsdp I/HiTouch_HiTouchSensor: HiTouch restricted: system app HiTouch don't exist. 2020-06-08 09:56:28.567 4541-6034/com.infosysta.mobile.mfjsdp D/HiTouch_PressGestureDetector: onAttached, package=com.infosysta.mobile.mfjsdp, windowType=1, mHiTouchRestricted=true 2020-06-08 09:56:28.766 4541-4674/com.infosysta.mobile.mfjsdp V/FA: Connection attempt already in progress 2020-06-08 09:56:28.801 4541-4674/com.infosysta.mobile.mfjsdp V/FA: Activity resumed, time: 105521 2020-06-08 09:56:28.825 4541-4685/com.infosysta.mobile.mfjsdp D/OpenGLRenderer: HWUI Binary is enabled 2020-06-08 09:56:28.828 4541-4541/com.infosysta.mobile.mfjsdp W/InputMethodManager: startInputReason = 1 2020-06-08 09:56:29.098 4541-4685/com.infosysta.mobile.mfjsdp E/ion: ioctl c0044901 failed with code -1: Invalid argument 2020-06-08 09:56:29.098 4541-4685/com.infosysta.mobile.mfjsdp I/chatty: uid=10158(com.infosysta.mobile.mfjsdp) RenderThread identical 1 line 2020-06-08 09:56:29.099 4541-4685/com.infosysta.mobile.mfjsdp E/ion: ioctl c0044901 failed with code -1: Invalid argument 2020-06-08 09:56:29.099 4541-4685/com.infosysta.mobile.mfjsdp D/OpenGLRenderer: endAllActiveAnimators on 0xc0322200 (IndicatorView) with handle 0xc5596530 2020-06-08 09:56:29.221 4541-4674/com.infosysta.mobile.mfjsdp V/FA: Connection attempt already in progress 2020-06-08 09:56:29.226 4541-4674/com.infosysta.mobile.mfjsdp V/FA: Connection attempt already in progress 2020-06-08 09:56:29.227 4541-4674/com.infosysta.mobile.mfjsdp D/FA: Connected to remote service 2020-06-08 09:56:29.231 4541-4674/com.infosysta.mobile.mfjsdp V/FA: Processing queued up service tasks: 4 2020-06-08 09:56:34.345 4541-4674/com.infosysta.mobile.mfjsdp V/FA: Inactivity, disconnecting from the service 2020-06-08 09:56:38.185 4541-4541/com.infosysta.mobile.mfjsdp D/ViewRootImpl[DashboardActivity]: surface should not be released 2020-06-08 09:56:38.272 4541-4541/com.infosysta.mobile.mfjsdp I/ViewRootImpl: jank_removeInvalidNode all the node in jank list is out of time.

I hope it's helpful. Best Regards.

nguyenhoanglam commented 4 years ago

@ma7moudAziz so you means the lib keeps showing loading progress after taking a photo or on the first load?

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, yes the lib keep showing the loading on the first load, and on my last comment I mentioned when open the camera I meant open the gallery I am using the image picker to get images from the gallery.

And thank you. Regards.

vjjustin commented 4 years ago

Any help here @nguyenhoanglam , please? Same issue for me. When opening the gallery it is just showing a loading symbol and is stuck there. If I use a camera and take a picture, after the picture is taken, we are back to the same album/loading page and nothing is happening after.

Using android 9. No error reported in logs. Using androidx and Kotlin 1.3.72, Android Studio 4.0, Java version 1.8, Gradle wrapper properties version 6.1.1.

Please let me know if you need any further details.

nguyenhoanglam commented 4 years ago

@ma7moudAziz @vjjustin Just tested again and it still works! I think you guys please send me a screen record and the device name that you use for more detail!

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Thank you for your efforts the device I am testing on is Huawei Y6 Prime 2019.

ezgif com-video-to-gif To be noted testing on an emulator even if it's version 9.0.0 will work, as it seems this issue is only happening on the device.

shanzeehashmi commented 4 years ago

Hello @nguyenhoanglam , please? Same issue for me. When opening the gallery it is just showing a loading symbol and is stuck there, in real device having android 9

nguyenhoanglam commented 4 years ago

Hi all, ultil now I can't debug this issue on my android 9 device. So I suggest you guys debug my lib's source to find out the issue:

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, I find the issue it seems that it's been stuck in this loop inside ImageFileLoader class:

do {

                val id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID))
                val name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME))
                val path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA))
                val bucketId = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID))
                val bucketName = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME))
                val file = makeSafeFile(path)
                if (file != null && file.exists()) {
                    val image = Image(id, name, path, bucketId, bucketName)
                    images.add(image)
                }
            } while (cursor.moveToPrevious())

cursor.moveToPrevious() is always true.

and here is an image showing you some variables if it helps: Screen Shot 2020-06-15 at 11 04 32 AM

And thank you for the effort, Best Regards.

nguyenhoanglam commented 4 years ago

@ma7moudAziz @robiky I followed your debug guide, made some changes in the loop block. But I still not sure that it'll fix the issue.

So I built an example apk and hope you will install it to check if the issue is gone! Please download the file in the link below: https://drive.google.com/file/d/1V-XAAIRcfxWuFICO2PKeCuWTTbuO4wrz/view?usp=sharing

KishanViramgama commented 4 years ago

application works good in Nokia 6.1 plus android 10 @nguyenhoanglam

nguyenhoanglam commented 4 years ago

@KishanViramgama Did your device have this issue before?

KishanViramgama commented 4 years ago

i have checked first time of this version works fine @nguyenhoanglam

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Thanks for the shared APK, I've tried it but the issue keeps occurring.

To be noted I've tried this on multiple phones it's working just fine the issue is only occurring on Huawei devices whatever the OS version, @shanzeehashmi, and @vjjustin can you please confirm the devices used for testing.

Also to be noted version 1.3.2 it's working fine even on the Huawei devices if this might help.

Best Regards.

shanzeehashmi commented 4 years ago

i had tested in android 9.0 in asus. The issue is occuring in this device as far my concern,, else i have tested in other version with real device, their it is fine

On Tue, 16 Jun 2020 at 12:50, Mahmoud Aziz notifications@github.com wrote:

Hi @nguyenhoanglam https://github.com/nguyenhoanglam, Thanks for the shared APK, I've tried it but the issue keeps occurring.

To be noted I've tried this on multiple phones it's working just fine the issue is only occurring on Huawei devices whatever the OS version, @shanzeehashmi https://github.com/shanzeehashmi, and @vjjustin https://github.com/vjjustin can you please confirm the devices used for testing.

Also to be noted version 1.3.2 it's working fine even on the Huawei devices if this might help.

Best Regards.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nguyenhoanglam/ImagePicker/issues/122#issuecomment-644582317, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKNUT3AO2NDHWORJVECS53LRW4MMPANCNFSM4NRN3ARQ .

ma7moudAziz commented 4 years ago

Thanks, @shanzeehashmi for the response.

nguyenhoanglam commented 4 years ago

@ma7moudAziz Are you sure cursor.moveToPrevious() is always true? Or maybe the cursor is iteratoring all images and it has not reached the end yet.

Does the debuger reach listener.onImageLoaded(images) line?

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, yes here there are 2 points drove me to this conclusion as follows:

The weird thing here that if I use Samsung or HTC or Sony devices even if the OS version was 9 the gallery opens normally with no issues but this only occurs for Huawei devices in my case and Asus as the case of @shanzeehashmi.

I know it's hard for you to fix such an issue, especially that it's not replicable locally for you (I've been there) but I'll try to help you as much as I can.

Best Regards.

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, I debugged it again to make sure, I notice that all the images returned are the same, for ex: all images in the array had the same name, the same id which means it's stuck on the first image as it seems "cursor.moveToPrevious()" it's not really getting the previous image

To be noted the function returns true.

Regards.

nguyenhoanglam commented 4 years ago

@ma7moudAziz Followed your description about cursor loop exceeds the maxium number of images. I've replaced the cursor's while loop by for index loop:

for (i in 0 until cursor.count) {
      cursor.moveToPosition(i)
      val id = cursor.getLong(idColumn)
      val name = cursor.getString(nameColumn)
      ...
}

This may prevent the loop exceeds 140 images.

About the 140 number of images instead of 114 images as you mentioned, I think there're some hiden images in the device that you don't know

After all, I rebuilt a new apk that using for index loop. Please install again and tell me the result! https://drive.google.com/file/d/1kHJRRqmJG88R6zjSzyn5nw2XNFQblG-A/view?usp=sharing

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Still the same not working, and about the images, this was where I stop the debug but it actually stays at the loop, and as I mentioned in the second comment all the images were with the same name and the same id, as it was returning the same image again and again and again.

But the weird thing here is this should've worked, but it still not can you please send me the source code of the second project to debug the For loop to check whats is really happening?

Regards.

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Any update on this?.

Regards.

reenasavaliya21 commented 4 years ago

Problem is here

var images = arrayListOf() if (cursor.moveToLast()) { do { val id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID)) val name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME)) val path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)) val bucketId = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID)) val bucketName = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME)) val file = makeSafeFile(path) if (file != null && file.exists()) { val image = Image(id, name, path, bucketId, bucketName) images.add(image) } } while (cursor.moveToPrevious()) }

Replace with below code

val temp = ArrayList(cursor.count) if (cursor.moveToFirst()) { do { if (Thread.interrupted()) { return } val id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID)) val name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME)) val path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)) val bucketId = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID)) val bucketName = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME)) val file = makeSafeFile(path) if (file != null && file.exists()) { var image: Image? = null if (id != null && name != null && path != null && bucketId != null && bucketName != null) { image = Image(id, name, path, bucketId, bucketName) if (image != null) images.add(image) } } } while (cursor.moveToNext()) } if (images == null) { images = java.util.ArrayList() images!!.clear() images!!.addAll(temp) } cursor.close() listener.onImageLoaded(images) Thread.interrupted()

nguyenhoanglam commented 4 years ago

@ma7moudAziz Thanks to @reenasavaliya21 's guide, I changed the loop code and built another apk. Please check it out! https://drive.google.com/file/d/1qMdhFTHCJA7X-WVeKyk-XH9A5ZHdnpWg/view?usp=sharing

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam, Thank you for the shared APK, this one is working perfectly for me. Thank you so much for your efforts. Best Regards.

nguyenhoanglam commented 4 years ago

@ma7moudAziz Finally, together we solved it!

One more step, the previous apk's code is not optimized. So I've updated the code and hope you will test it once again!

https://drive.google.com/file/d/1PmVrP4Mslu4_X5wXduxuAv9D1HwemaWu/view?usp=sharing

vjjustin commented 4 years ago

Hi, Just tested the apk. This works for me too. This is Xiaomi redmi phone. Thanks for the great work.

Sorry couldn't test/reply earlier because was busy with a major update on my app.

On Mon, 29 Jun, 2020, 9:43 PM Nguyen Hoang Lam, notifications@github.com wrote:

@ma7moudAziz https://github.com/ma7moudAziz Finally, together we solved it!

One more step, the previous apk's code is not optimized. So I'v updated the code and hope you will test it once again!

https://drive.google.com/file/d/1PmVrP4Mslu4_X5wXduxuAv9D1HwemaWu/view?usp=sharing http://url

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nguyenhoanglam/ImagePicker/issues/122#issuecomment-651219851, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZ2VFBAZSZXHFX3S32UOLRZC4UNANCNFSM4NRN3ARQ .

reenasavaliya21 commented 4 years ago

hey @nguyenhoanglam i am using your imagepikcer dependncy and i am facing issue, I was not able to show my most recent photos on top. it show images into Ascending order....please help me to handle this issue.

nguyenhoanglam commented 4 years ago

@reenasavaliya21 Please try this example apk. If it works as your expectation, I will release a new version soon!

https://drive.google.com/file/d/1PmVrP4Mslu4_X5wXduxuAv9D1HwemaWu/view?usp=sharing

ma7moudAziz commented 4 years ago

Hi @nguyenhoanglam , Thank you so much, it's working now. I will close this for now as it's been resolved. Best Regards.

reenasavaliya21 commented 4 years ago

Yes It's working well now.,Thank you.

On Tue, Jun 30, 2020 at 11:33 AM Nguyen Hoang Lam notifications@github.com wrote:

@reenasavaliya21 https://github.com/reenasavaliya21 Please try this example apk. If it works as your expectation, I will release a new version soon!

https://drive.google.com/file/d/1PmVrP4Mslu4_X5wXduxuAv9D1HwemaWu/view?usp=sharing http://url

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nguyenhoanglam/ImagePicker/issues/122#issuecomment-651561251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIAEFIAMX64B2BQW6ORPEH3RZF52VANCNFSM4NRN3ARQ .