Search in sources :

Example 66 with ViewTreeObserver

use of android.view.ViewTreeObserver in project android_frameworks_base by ResurrectionRemix.

the class ActivityChooserView method onDetachedFromWindow.

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    ActivityChooserModel dataModel = mAdapter.getDataModel();
    if (dataModel != null) {
        dataModel.unregisterObserver(mModelDataSetOberver);
    }
    ViewTreeObserver viewTreeObserver = getViewTreeObserver();
    if (viewTreeObserver.isAlive()) {
        viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
    }
    if (isShowingPopup()) {
        dismissPopup();
    }
    mIsAttachedToWindow = false;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 67 with ViewTreeObserver

use of android.view.ViewTreeObserver in project CompactCalendarView by SundeepK.

the class CompactCalendarTab method openCalendarOnCreate.

private void openCalendarOnCreate(View v) {
    final RelativeLayout layout = (RelativeLayout) v.findViewById(R.id.main_content);
    ViewTreeObserver vto = layout.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT < 16) {
                layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
            compactCalendarView.showCalendarWithAnimation();
        }
    });
}
Also used : RelativeLayout(android.widget.RelativeLayout) ViewTreeObserver(android.view.ViewTreeObserver)

Example 68 with ViewTreeObserver

use of android.view.ViewTreeObserver in project android_frameworks_base by ResurrectionRemix.

the class PopupWindow method detachFromAnchor.

private void detachFromAnchor() {
    final View anchor = mAnchor != null ? mAnchor.get() : null;
    if (anchor != null) {
        final ViewTreeObserver vto = anchor.getViewTreeObserver();
        vto.removeOnScrollChangedListener(mOnScrollChangedListener);
    }
    final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
    if (anchorRoot != null) {
        anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener);
    }
    mAnchor = null;
    mAnchorRoot = null;
    mIsAnchorRootAttached = false;
}
Also used : View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver)

Example 69 with ViewTreeObserver

use of android.view.ViewTreeObserver in project android_frameworks_base by ResurrectionRemix.

the class PopupWindow method attachToAnchor.

private void attachToAnchor(View anchor, int xoff, int yoff, int gravity) {
    detachFromAnchor();
    final ViewTreeObserver vto = anchor.getViewTreeObserver();
    if (vto != null) {
        vto.addOnScrollChangedListener(mOnScrollChangedListener);
    }
    final View anchorRoot = anchor.getRootView();
    anchorRoot.addOnAttachStateChangeListener(mOnAnchorRootDetachedListener);
    mAnchor = new WeakReference<>(anchor);
    mAnchorRoot = new WeakReference<>(anchorRoot);
    mIsAnchorRootAttached = anchorRoot.isAttachedToWindow();
    mAnchorXoff = xoff;
    mAnchorYoff = yoff;
    mAnchoredGravity = gravity;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver) View(android.view.View)

Example 70 with ViewTreeObserver

use of android.view.ViewTreeObserver in project ActionBarSherlock by JakeWharton.

the class ActivityChooserView method dismissPopup.

/**
     * Dismisses the popup window with activities.
     *
     * @return True if dismissed, false if already dismissed.
     */
public boolean dismissPopup() {
    if (isShowingPopup()) {
        getListPopupWindow().dismiss();
        ViewTreeObserver viewTreeObserver = getViewTreeObserver();
        if (viewTreeObserver.isAlive()) {
            viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
        }
    }
    return true;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

ViewTreeObserver (android.view.ViewTreeObserver)222 View (android.view.View)56 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)25 ImageView (android.widget.ImageView)25 TextView (android.widget.TextView)15 ViewGroup (android.view.ViewGroup)14 SuppressLint (android.annotation.SuppressLint)13 AdapterView (android.widget.AdapterView)12 TypedArray (android.content.res.TypedArray)7 Test (org.junit.Test)7 RectF (android.graphics.RectF)6 DisplayMetrics (android.util.DisplayMetrics)6 ViewParent (android.view.ViewParent)6 LinearLayout (android.widget.LinearLayout)6 ListView (android.widget.ListView)6 Resources (android.content.res.Resources)5 ValueAnimator (android.animation.ValueAnimator)4 TargetApi (android.annotation.TargetApi)4 Activity (android.app.Activity)4 Paint (android.graphics.Paint)4