andkulikov / Transitions-Everywhere

Set of extra Transitions on top of Jetpack Transitions Library
Apache License 2.0
4.83k stars 486 forks source link

Crashes in ViewUtils #83

Closed AlexNsbmr closed 6 years ago

AlexNsbmr commented 6 years ago

I'm experiencing some crashes in the library in ViewUtils:

ViewUtils.java line 177
com.transitionseverywhere.utils.ViewUtils$ViewUtilsKitKat.isLaidOut

Here is the stacktrace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.View.isLaidOut()' on a null object reference
       at com.transitionseverywhere.utils.ViewUtils$ViewUtilsKitKat.isLaidOut(ViewUtils.java:177)
       at com.transitionseverywhere.utils.ViewUtils.isLaidOut(ViewUtils.java:207)
       at com.transitionseverywhere.TransitionManager.beginDelayedTransition(TransitionManager.java:424)
       at x.x.x.ui.a.bb$cc$1$run$1.run(bb.kt:292)
       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:6940)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
andkulikov commented 6 years ago

Hi, As you can easily check via sources it means you are calling TransitionManager.beginDelayedTransition with null first parameter ViewGroup sceneRoot. its not marked as NonNull currently, but in fact it is. Please check why you are doing so and add null check. An animation can't be started on a null view obviously.

AlexNsbmr commented 6 years ago

Thank you for your quick feedback @andkulikov. It would be great to add more safety with a @NonNull on the ViewGroup parameter like in the android transition support library for a next version. Keep up the good work !

andkulikov commented 6 years ago

@AlexNsbmr Thanks for the idea. I added nullability annotations for every method in the library and released version 1.8.0 with it.

AlexNsbmr commented 6 years ago

@andkulikov Thank you, you're awesome!