From def4c23899a917d0387a97764cb1ed1ace29b9ea Mon Sep 17 00:00:00 2001 From: skydoves Date: Tue, 17 Sep 2024 20:33:43 +0900 Subject: [PATCH] Check if the anchor view's window token is valid --- balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt b/balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt index f1a7c4f..01b7fee 100644 --- a/balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt +++ b/balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt @@ -919,8 +919,11 @@ public class Balloon private constructor( // Sometimes there is a concurrency issue between show and dismiss the popupWindow. (#149) if (bodyWindow.contentView.parent != null) return false - // we should check the anchor view is attached to the parent's window. - return ViewCompat.isAttachedToWindow(anchor) + // We should check if the anchor view's window token is valid. + if (!anchor.windowToken.isBinderAlive) return false + + // We should check the anchor view is attached to the parent's window. + return anchor.isAttachedToWindow } private fun showOverlayWindow(anchor: View, subAnchors: List) {