Code example for ViewTreeObserver

Methods: isAlive, removeGlobalOnLayoutListener

0
    @SuppressWarnings("deprecation") 
    public void onDismiss() { 
        mPopup = null;
        mMenu.close();
        if (mTreeObserver != null) {
            if (!mTreeObserver.isAlive()) {
                mTreeObserver = mAnchorView.getViewTreeObserver();
            } 
            mTreeObserver.removeGlobalOnLayoutListener(this);
            mTreeObserver = null;
        } 
        if (mAnchorView instanceof View_HasStateListenerSupport) {
            ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this);
        } 
    } 
 
    public boolean isShowing() { 
        return (mPopup != null) && mPopup.isShowing();
    } 
 
    @Override