skydoves / Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
https://skydoves.github.io/libraries/balloon/html/balloon/com.skydoves.balloon/index.html
Apache License 2.0
3.71k stars 290 forks source link

Circular animation balloons can't be shown more than once if set to focusable #299

Closed danielwilson1702 closed 2 years ago

danielwilson1702 commented 2 years ago

Please complete the following information:

Describe the Bug:

Giving a balloon an animation type of circular and setting it to focusable breaks the ability to show a balloon more than once.

I have a balloon which I need to make focusable due to it containing a text field, with a circular animation. Making it focusable appears to somehow set isAttachedToWindow to false. I'm not sure why. That means when it is dismissed the circularUnRevealed code is not executed which means dismissWindow() is not called.

Expected Behavior:

Setting the bodyWindow to focusable allows the circular animation to execute and if not, isShowing is at least set to false. I'm not sure what the correct solution here is or the cause of it. To reproduce you just need to have the ProfileBalloonFactory builder call setFocusable(true).Then verify that a second click on the image doesn't draw the balloon.

Thanks for your library, it's very good!

skydoves commented 2 years ago

Hey @danielwilson1702, sorry for the delayed response. The circular reveal animation uses ViewAnimationUtils internally and it seems to happen a bug if the animation run with the PopupWindow. So Balloon set focusable as false if you apply the circular animation to the Balloon.Builder - https://github.com/skydoves/Balloon/blob/main/balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt#L2407

One of the tricky ways is tracking the finish of the animation and calling the setFucusable(true) again. I'll keep finding other solutions to resolve it, but for now, there are no great solutions from my side.

If I find a better solution, I'll let you know. Thanks!