Search in sources :

Example 21 with ViewTreeObserver

use of android.view.ViewTreeObserver in project platform_frameworks_base by android.

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.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
        }
    }
    return true;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 22 with ViewTreeObserver

use of android.view.ViewTreeObserver in project platform_frameworks_base by android.

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 23 with ViewTreeObserver

use of android.view.ViewTreeObserver in project JamsMusicPlayer by psaravan.

the class DeferredRequestCreator method cancel.

void cancel() {
    callback = null;
    ImageView target = this.target.get();
    if (target == null) {
        return;
    }
    ViewTreeObserver vto = target.getViewTreeObserver();
    if (!vto.isAlive()) {
        return;
    }
    vto.removeOnPreDrawListener(this);
}
Also used : ImageView(android.widget.ImageView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 24 with ViewTreeObserver

use of android.view.ViewTreeObserver in project weiciyuan by qii.

the class PhotoViewAttacher method cleanup.

/**
     * Clean-up the resources attached to this object. This needs to be called when the ImageView is
     * no longer used. A good example is from {@link android.view.View#onDetachedFromWindow()} or
     * from {@link android.app.Activity#onDestroy()}. This is automatically called if you are using
     * {@link uk.co.senab.photoview.PhotoView}.
     */
@SuppressWarnings("deprecation")
public final void cleanup() {
    if (null == mImageView) {
        // cleanup already done
        return;
    }
    final ImageView imageView = mImageView.get();
    if (null != imageView) {
        // Remove this as a global layout listener
        ViewTreeObserver observer = imageView.getViewTreeObserver();
        if (null != observer && observer.isAlive()) {
            observer.removeGlobalOnLayoutListener(this);
        }
        // Remove the ImageView's reference to this
        imageView.setOnTouchListener(null);
        // make sure a pending fling runnable won't be run
        cancelFling();
    }
    if (null != mGestureDetector) {
        mGestureDetector.setOnDoubleTapListener(null);
    }
    // Clear listeners too
    mMatrixChangeListener = null;
    mPhotoTapListener = null;
    mViewTapListener = null;
    // Finally, clear ImageView
    mImageView = null;
}
Also used : ImageView(android.widget.ImageView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 25 with ViewTreeObserver

use of android.view.ViewTreeObserver in project material by rey5137.

the class Spinner method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    setSelection(ss.position);
    if (ss.showDropdown) {
        ViewTreeObserver vto = getViewTreeObserver();
        if (vto != null) {
            final ViewTreeObserver.OnGlobalLayoutListener listener = new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    showPopup();
                    final ViewTreeObserver vto = getViewTreeObserver();
                    if (vto != null)
                        vto.removeGlobalOnLayoutListener(this);
                }
            };
            vto.addOnGlobalLayoutListener(listener);
        }
    }
}
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