leandroBorgesFerreira / LoadingButtonAndroid

A button to substitute the ProgressDialog
MIT License
1.95k stars 214 forks source link

NullPointerException when calling doneLoadingAnimation #40

Closed Lexycon closed 6 years ago

Lexycon commented 6 years ago

Well, I get a NPE when calling doneLoadingAnimation. I don't get it why, actually I have some more buttons in different fragments and they are working perfectly. If I debug and compare both circularProgressButton variables, they don't have any difference. circularProgressButton is not Null. Used version 1.8.4 and 1.12.0.

Edit: I have a callback/interface in the AsyncTask to the Fragment, which will then call this method. I guess this could be the issue?, but actually I am doing the same in the other fragments...

  E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.sample.lexycon, PID: 16270
                  java.lang.NullPointerException: Attempt to invoke virtual method 'void br.com.simplepass.loading_button_lib.animatedDrawables.CircularRevealAnimatedDrawable.draw(android.graphics.Canvas)' on a null object reference
                      at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.drawDoneAnimation(CircularProgressButton.java:316)
                      at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.onDraw(CircularProgressButton.java:232)
                      at android.view.View.draw(View.java:18319)
                      at android.view.View.updateDisplayListIfDirty(View.java:17297)
                      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
                      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
                      at android.view.View.updateDisplayListIfDirty(View.java:17260)
                      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
                      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
                      at android.view.View.updateDisplayListIfDirty(View.java:17260)
                      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
                      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
                      at android.view.View.updateDisplayListIfDirty(View.java:17260)
                      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
                      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
                      at android.view.View.updateDisplayListIfDirty(View.java:17260)
                      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
                      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
                      at android.view.View.updateDisplayListIfDirty(View.java:17260)
                      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
                      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
                      at android.view.View.updateDisplayListIfDirty(View.java:17260)
                      at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:666)
                      at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:672)
                      at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:780)
                      at android.view.ViewRootImpl.draw(ViewRootImpl.java:3112)
                      at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2908)
                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2502)
                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1509)
                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7051)
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
                      at android.view.Choreographer.doCallbacks(Choreographer.java:702)
                      at android.view.Choreographer.doFrame(Choreographer.java:638)
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
                      at android.os.Handler.handleCallback(Handler.java:751)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6692)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Lexycon commented 6 years ago

Well that was a fail by me. I had to call the doneLoadingAnimation inside runOnUiThread(), because my callback was obv. executed in the Asynctask...

KishanViramgama commented 6 years ago

hii i am try your library

run time exception throw java.lang.NullPointerException use in

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.category_bg); int color = Color.parseColor("#FF4081"); btn.doneLoadingAnimation(color, largeIcon);