Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Null pointer Exception when combining fadein and fadeout animation #37

Open
bitsydarel opened this issue Oct 20, 2017 · 1 comment
Open

Comments

@bitsydarel
Copy link

bitsydarel commented Oct 20, 2017

Hi, trying to animate by button with the following code but getting null exception not from my code but from internal code.

ViewAnimator.animate(binding.liveFavorite)
.zoomIn()
.fadeOut()
.custom(AnimationListener.Update { view, _ -> view.setImageResource(R.drawable.ic_bookmarked) } )
.fadeIn()
.zoomOut()
.start()

Stacktrace:

FATAL EXCEPTION: main
Process: com.dbeginc.dbweather, PID: 5806
java.lang.NullPointerException: Attempt to get length of null array
at android.animation.ValueAnimator.initAnimation(ValueAnimator.java:534)
at android.animation.ValueAnimator.startAnimation(ValueAnimator.java:1263)
at android.animation.ValueAnimator.access$100(ValueAnimator.java:67)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:724)
at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:896)
at android.view.Choreographer.doCallbacks(Choreographer.java:698)
at android.view.Choreographer.doFrame(Choreographer.java:630)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:882)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)

@RahulSDeshpande
Copy link

RahulSDeshpande commented Jan 8, 2018

Hey @bitsydarel !!

I initially thought that the reason is the anonymous inner-type class in custom(--) method.
But I was wrong.

The reason is the 2nd parameter of the custom(-,-...) method is float... values;
i.e., it is expecting the valueAnimator float array values which you are not passing & is thus erroring out in your animation with Attempt to get length of null array.. exception.

Let us know if this fixes your issue :)

Cheers 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants