BrotherV / Floating-ArcMenu

A prety menu for all application
129 stars 35 forks source link

NPE: FloatingActionButton.SwitchIconAnimator #24

Open sviro opened 5 years ago

sviro commented 5 years ago

Hi, here is a stack trace from a crash we observed in our app using your library:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setAlpha(int)' on a null object reference at com.bvapp.arcmenulibrary.widget.FloatingActionButton$SwitchIconAnimator.run(FloatingActionButton.java:719) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

BrotherV commented 5 years ago

If you check the error you will find out the problem happened because you passed a null Drawable as an icon to FloatActionButton. If you want to add a FloatActionButton and add an icon programmatically, you can pass a Drawable by ResId or by a Drawable. Also I completely deactivated SwitchIconAnimator class in this library whereas you used it manually and this crashed happened because mPrevIcon object was null.