Aghajari / ZoomHelper

ZoomHelper will make any view to be zoomable just like Instagram pinch-to-zoom
Apache License 2.0
247 stars 22 forks source link

Incident collected through crashlytics #8

Closed adrianddpp closed 3 years ago

adrianddpp commented 3 years ago

Hi! First of all, thank you very much for this library. I attach the report of a crash produced by this library, I think it can be useful for me and more people.

Android 9 Redmi 5 Plus

Fatal Exception: java.lang.NullPointerException at com.aghajari.zoomhelper.ZoomHelper$dismissDialogAndViews$1.run(ZoomHelper.kt:351) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6810) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

If you could help me to solve this I would appreciate it, thanks

Aghajari commented 3 years ago

Hi, Which version of the lib are you using? i believe the last version works fine!

adrianddpp commented 3 years ago

Hello, thanks for answering first of all. The version I have installed is 1.0.1, I have seen that there is a higher version, I am going to apply this update to test if the error goes away :)

It seems that the problem occurs on this line ZoomHelper.kt:351

val parent = zoomableView!!.parent as ViewGroup;

Maybe it could be interesting to control that zoomableView is a viewGroup, this could be an alternative, and that is not null

(zoomableView!!.parent as? ViewGroup)?.let{ parent->
  parent.removeView(zoomableView)
                    zoomableViewParent?.addView(zoomableView!!, viewIndex!!, viewLayoutParams)
                    zoomableViewParent?.removeView(placeHolderView)
                    dismissDialog()
}

It seems that since I added this fire I have received more reports. I could upload a pull request if you see it interesting.

Regards!

Aghajari commented 3 years ago

Hello again, I've fixed this error on v1.0.2, check it out If there is still a problem, let me know or just send a pull request.

Good luck.

adrianddpp commented 3 years ago

Hi! You're right, when I updated I saw that the problem has been solved, sorry for this issue :)

Good luck