darsh2 / MultipleImageSelect

Android library that provides for multiple image selection.
Apache License 2.0
300 stars 112 forks source link

NullPointerException on fast tapping #12

Closed BassDay closed 8 years ago

BassDay commented 8 years ago

Hello. We hope you still provide support for MultipleImageSelect.

We've met some issues while using your image picker, which you can reproduce as follows:

1) Open Gallery 2) Perform a fast tap on the "Photos" folder 3) Perform a fast tap on an image which thumbnail wasn't yet loaded 4) Perform a fast tap on "Add" button

As the result, the activity reloads, and then, when you try to choose any of available images and hit the "Add" button, you'll get a crash with the following stack trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Handler.removeCallbacksAndMessages(java.lang.Object)' on a null object reference android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3656) android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3710) android.app.ActivityThread.access$1400(ActivityThread.java:147) android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) android.os.Handler.dispatchMessage(Handler.java:102) android.os.Looper.loop(Looper.java:135) android.app.ActivityThread.main(ActivityThread.java:5260) java.lang.reflect.Method.invoke(Native Method) java.lang.reflect.Method.invoke(Method.java:372) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Handler.removeCallbacksAndMessages(java.lang.Object)' on a null object reference com.darsh.multipleimageselect.activities.ImageSelectActivity.onStop(ImageSelectActivity.java:150) android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1261) android.app.Activity.performStop(Activity.java:6127) android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3651) android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3710) android.app.ActivityThread.access$1400(ActivityThread.java:147) android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) android.os.Handler.dispatchMessage(Handler.java:102) android.os.Looper.loop(Looper.java:135) android.app.ActivityThread.main(ActivityThread.java:5260) java.lang.reflect.Method.invoke(Native Method) java.lang.reflect.Method.invoke(Method.java:372) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

We have suceeded to reproduce this on following devices:

Dalvik/2.1.0 (Linux; U; Android 6.0; Nexus 5X Build/MDA89E) Dalvik/2.1.0 (Linux; U; Android 5.0; K016 Build/LRX21V)

darsh2 commented 8 years ago

Hey, thank you for the detailed bug report. I tried it on my device (Android 5.1.1; OnePlus One) to see if I could reproduce the error, but it seemed to work fine. It's more likely to be device specific.

From the looks of it, the handler object points to a null reference in onStop() despite being initialized in onStart(). Have to look into this in more detail.

In the meantime, if you could fix this issue and send a pull request, it will be greatly appreciated.

BassDay commented 8 years ago

Hello,

Thank you for the fast response. I'll try to fix it, even though I'm not that experienced yet.

In the meantime, I have some propositions:

Sorry for my bad English, I don't have much practice these days.

Best regards, Sergey

P.S. We are using your module in PictureJam Collage Maker app, you can give it a try if you want to ;)

Среда, 6 апреля 2016, 19:26 +06:00 от Darshan Dorai notifications@github.com:

Hey, thank you for the detailed bug report. I tried it on my device (Android 5.1.1; OnePlus One) to see if I could reproduce the error, but it seemed to work fine. It's more likely to be device specific. From the looks of it, the handler object points to a null reference in onStop() despite being initialized in onStart(). Have to look into this in more detail. In the meantime, if you could fix this issue and send a pull request, it will be greatly appreciated. — You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub

darsh2 commented 8 years ago

It would be great if you could provide translations. Glad to hear that you are using this library, if you could share the link to your app, I'll add it to this repository's readme.

Adding photos from multiple folders and a horizontal linear layout to scroll through selected photos are nice features to have. However due to university couldn't devote as much time as I would have liked. Will work on these features soon. Thanks for the suggestion :)

darsh2 commented 8 years ago

Closing this issue as commit 2717eb3 solves it.