Android ViewTreeObserver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ViewTreeObserver class.

This code example shows how to use the following methods:isAlive, removeGlobalOnLayoutListener
 
    public void onDismiss() { 
        mPopup = null;
        mMenu.close();
        if (mTreeObserver != null) {
            if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver();
            mTreeObserver.removeGlobalOnLayoutListener(this);
            mTreeObserver = null;
        } 
        ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this);
    } 
 
    public boolean isShowing() { 
        return mPopup != null && mPopup.isShowing();
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        MenuAdapter adapter = mAdapter;
        adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0);
7
CodeRank
This code example shows how to use the following methods:isAlive, removeOnPreDrawListener
        // in this case. 
        if (Build.VERSION.SDK_INT >= 11 && treeObserver != null && treeObserver.isAlive()) {
            treeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                @Override 
                public boolean onPreDraw() { 
                    if (treeObserver.isAlive()) {
                        treeObserver.removeOnPreDrawListener(this);
                    } 
 
                    mFramePoster.postFirstAnimationFrame();
                    return true; 
                } 
            }); 
        } else { 
            mFramePoster.postFirstAnimationFrame();
        } 
 
        if (mListeners != null) {
            for (PropertyAnimationListener listener : mListeners) {
                listener.onPropertyAnimationStart();
6
CodeRank
This code example shows how to use the following methods:isAlive, removeGlobalOnLayoutListener
 
    public void onDismiss() { 
        mPopup = null;
        mMenu.close();
        if (mTreeObserver != null) {
            if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver();
            mTreeObserver.removeGlobalOnLayoutListener(this);
            mTreeObserver = null;
        } 
        ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this);
    } 
 
    public boolean isShowing() { 
        return mPopup != null && mPopup.isShowing();
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        MenuAdapter adapter = mAdapter;
        adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0);
7
CodeRank
This code example shows how to use the following methods:isAlive, removeGlobalOnLayoutListener
 
    public void onDismiss() { 
        mPopup = null;
        mMenu.close();
        if (mTreeObserver != null) {
            if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver();
            mTreeObserver.removeGlobalOnLayoutListener(this);
            mTreeObserver = null;
        } 
        mAnchorView.removeOnAttachStateChangeListener(this);
    } 
 
    public boolean isShowing() { 
        return mPopup != null && mPopup.isShowing();
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        MenuAdapter adapter = mAdapter;
        adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0);
6
CodeRank
This code example shows how to use the following methods:isAlive, removeGlobalOnLayoutListener
    @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);
        } 
    } 
 
    @Override 
    public void onGlobalLayout() { 
        if (isShowing()) { 
5
CodeRank
This code example shows how to use the following methods:getViewTreeObserver, removeOnTouchModeChangeListener
 
    @Override 
    protected void onAttachedToWindow() { 
        super.onAttachedToWindow(); 
        final TabHost tabhost = (TabHost) getRootView().findViewById(android.R.id.tabhost);
        tabhost.getViewTreeObserver().removeOnTouchModeChangeListener(tabhost);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:removeOnGlobalLayoutListener
This code example shows how to use the following methods:getViewTreeObserver, removeOnTouchModeChangeListener
 
    @Override 
    protected void onAttachedToWindow() { 
        super.onAttachedToWindow(); 
        final TabHost tabhost = (TabHost) getRootView().findViewById(android.R.id.tabhost);
        tabhost.getViewTreeObserver().removeOnTouchModeChangeListener(tabhost);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getViewTreeObserver, removeOnTouchModeChangeListener
 
    @Override 
    protected void onAttachedToWindow() { 
        super.onAttachedToWindow(); 
        final TabHost tabhost = (TabHost) getRootView().findViewById(android.R.id.tabhost);
        tabhost.getViewTreeObserver().removeOnTouchModeChangeListener(tabhost);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:isAlive, removeGlobalOnLayoutListener
 
	@SuppressWarnings("deprecation") 
	public void onDismiss() { 
		mPopup = null;
		if (mTreeObserver != null) {
			if (!mTreeObserver.isAlive()) {
				mTreeObserver = mAnchorView.getViewTreeObserver();
			} 
			mTreeObserver.removeGlobalOnLayoutListener(this);
			mTreeObserver = null;
		} 
	} 
 
	public boolean isShowing() { 
		return mPopup != null && mPopup.isShowing();
	} 
 
	@Override 
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
4
CodeRank

Related Android ViewTreeObserver Questions & Answers:

See Code Examples for Android ViewTreeObserver Methods: