@@ -78,8 +78,8 @@ public class SimpleTooltip implements PopupWindow.OnDismissListener {
7878 private static final int mDefaultArrowHeightRes = R .dimen .simpletooltip_arrow_height ;
7979
8080 private final Context mContext ;
81- private final OnDismissListener mOnDismissListener ;
82- private final OnShowListener mOnShowListener ;
81+ private OnDismissListener mOnDismissListener ;
82+ private OnShowListener mOnShowListener ;
8383 private PopupWindow mPopupWindow ;
8484 private final int mGravity ;
8585 private final boolean mDismissOnInsideTouch ;
@@ -94,7 +94,7 @@ public class SimpleTooltip implements PopupWindow.OnDismissListener {
9494 private final boolean mTransparentOverlay ;
9595 private final float mMaxWidth ;
9696 private View mOverlay ;
97- private final ViewGroup mRootView ;
97+ private ViewGroup mRootView ;
9898 private final boolean mShowArrow ;
9999 private ImageView mArrowView ;
100100 private final Drawable mArrowDrawable ;
@@ -297,15 +297,19 @@ public void onDismiss() {
297297 mAnimator .removeAllListeners ();
298298 mAnimator .end ();
299299 mAnimator .cancel ();
300+ mAnimator = null ;
300301 }
301302 }
302303
303304 if (mRootView != null && mOverlay != null ) {
304305 mRootView .removeView (mOverlay );
305306 }
307+ mRootView = null ;
308+ mOverlay = null ;
306309
307310 if (mOnDismissListener != null )
308311 mOnDismissListener .onDismiss (this );
312+ mOnDismissListener = null ;
309313
310314 mPopupWindow = null ;
311315 }
@@ -346,8 +350,10 @@ public boolean onTouch(View v, MotionEvent event) {
346350 private final ViewTreeObserver .OnGlobalLayoutListener mLocationLayoutListener = new ViewTreeObserver .OnGlobalLayoutListener () {
347351 @ Override
348352 public void onGlobalLayout () {
349- if (dismissed )
353+ if (dismissed ) {
354+ SimpleTooltipUtils .removeOnGlobalLayoutListener (mPopupWindow .getContentView (), this );
350355 return ;
356+ }
351357
352358 if (mMaxWidth > 0 && mContentView .getWidth () > mMaxWidth ) {
353359 SimpleTooltipUtils .setWidth (mContentView , mMaxWidth );
@@ -368,10 +374,10 @@ public void onGlobalLayout() {
368374 private final ViewTreeObserver .OnGlobalLayoutListener mArrowLayoutListener = new ViewTreeObserver .OnGlobalLayoutListener () {
369375 @ Override
370376 public void onGlobalLayout () {
377+ SimpleTooltipUtils .removeOnGlobalLayoutListener (mPopupWindow .getContentView (), this );
371378 if (dismissed )
372379 return ;
373380
374- SimpleTooltipUtils .removeOnGlobalLayoutListener (mPopupWindow .getContentView (), this );
375381 mPopupWindow .getContentView ().getViewTreeObserver ().addOnGlobalLayoutListener (mAnimationLayoutListener );
376382 mPopupWindow .getContentView ().getViewTreeObserver ().addOnGlobalLayoutListener (mShowLayoutListener );
377383 if (mShowArrow ) {
@@ -415,12 +421,14 @@ public void onGlobalLayout() {
415421 private final ViewTreeObserver .OnGlobalLayoutListener mShowLayoutListener = new ViewTreeObserver .OnGlobalLayoutListener () {
416422 @ Override
417423 public void onGlobalLayout () {
424+ SimpleTooltipUtils .removeOnGlobalLayoutListener (mPopupWindow .getContentView (), this );
418425 if (dismissed )
419426 return ;
420427
421- SimpleTooltipUtils .removeOnGlobalLayoutListener (mPopupWindow .getContentView (), this );
422428 if (mOnShowListener != null )
423429 mOnShowListener .onShow (SimpleTooltip .this );
430+ mOnShowListener = null ;
431+
424432 mContentLayout .setVisibility (View .VISIBLE );
425433 }
426434 };
@@ -471,8 +479,10 @@ public void onAnimationEnd(Animator animation) {
471479 private final ViewTreeObserver .OnGlobalLayoutListener mAutoDismissLayoutListener = new ViewTreeObserver .OnGlobalLayoutListener () {
472480 @ Override
473481 public void onGlobalLayout () {
474- if (dismissed )
482+ if (dismissed ) {
483+ SimpleTooltipUtils .removeOnGlobalLayoutListener (mPopupWindow .getContentView (), this );
475484 return ;
485+ }
476486
477487 if (!mRootView .isShown ())
478488 dismiss ();
0 commit comments