AviranAbady / CookieBar2

Android library for displaying text messages, notifications and alerts at the top or bottom of the screen. A great alternative for toast and snackbar alerts.
Apache License 2.0
668 stars 74 forks source link

IllegalStateException #32

Open achatina opened 2 years ago

achatina commented 2 years ago

Hi! Have an exception on the 1.1.5 version:

Fatal Exception: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. at android.view.ViewGroup.addViewInner(ViewGroup.java:5212) at android.view.ViewGroup.addView(ViewGroup.java:5035) at android.view.ViewGroup.addView(ViewGroup.java:4972) at android.view.ViewGroup.addView(ViewGroup.java:4945) at org.aviran.cookiebar2.CookieBar$1.onDismiss(CookieBar.java:106) at org.aviran.cookiebar2.Cookie.cookieListenerDismiss(Cookie.java:325) at org.aviran.cookiebar2.Cookie.dismiss(Cookie.java:278) at org.aviran.cookiebar2.Cookie.dismiss(Cookie.java:261) at org.aviran.cookiebar2.Cookie$5.onAnimationEnd(Cookie.java:401) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1111) at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1242) at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1484) at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146) at android.animation.AnimationHandler.access$100(AnimationHandler.java:37) at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1039) at android.view.Choreographer.doCallbacks(Choreographer.java:860) at android.view.Choreographer.doFrame(Choreographer.java:781) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1026) at android.os.Handler.handleCallback(Handler.java:914) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:225) at android.app.ActivityThread.main(ActivityThread.java:7563) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)

Seems like it is related to #20 and #28. Can't reproduce it by myself, but there are tons of them in our Crashlitycs. Just add a check parent.contains(view) here: at org.aviran.cookiebar2.CookieBar$1.onDismiss(CookieBar.java:106)

Should probably fix an error. or assert with try-catch

AviranAbady commented 2 years ago

Thank you for reporting @achatina I will take a look