android.view.ViewTreeObserver#removeGlobalOnLayoutListener ( )源码实例Demo

下面列出了android.view.ViewTreeObserver#removeGlobalOnLayoutListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ImagePicker   文件: CropView.java
@SuppressWarnings("deprecation")
private void cleanup()
{
    cancelFling();

    if (null != mGestureDetector)
    {
        mGestureDetector.setOnDoubleTapListener(null);
    }

    ViewTreeObserver observer = getViewTreeObserver();
    if (null != observer && observer.isAlive())
    {
        observer.removeGlobalOnLayoutListener(this);
    }

    setImageBitmap(null);

    mBitmapDisplayed.recycle();
}
 
源代码2 项目: sa-sdk-android   文件: EditState.java
private void cleanUp() {
    if (mAlive) {
        final View viewRoot = mViewRoot.get();
        if (null != viewRoot) {
            final ViewTreeObserver observer = viewRoot.getViewTreeObserver();
            if (observer.isAlive()) {
                if (Build.VERSION.SDK_INT < 16) {
                    observer.removeGlobalOnLayoutListener(this);
                } else {
                    observer.removeOnGlobalLayoutListener(this);
                }
            }
        }
        mEdit.cleanup();
    }
    mAlive = false;
}
 
源代码3 项目: Nimingban   文件: PhotoViewAttacher.java
/**
 * 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 void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
源代码4 项目: ImageSelector   文件: CropPhotoViewAttacher.java
/**
* 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 View#onDetachedFromWindow()} or
* from {@link android.app.Activity#onDestroy()}.
*/
  @SuppressWarnings("deprecation")
  public void cleanup() {
   if (null == mImageView) {
	   return; // cleanup already done
   }

   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;
  }
 
源代码5 项目: zhangshangwuda   文件: ActivityChooserView.java
/**
 * 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;
}
 
源代码6 项目: imsdk-android   文件: PhotoViewAttacher.java
/**
 * 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 View#onDetachedFromWindow()} or
 * from {@link android.app.Activity#onDestroy()}. This is automatically called if you are using
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
源代码7 项目: MultiView   文件: ImageViewScaler.java
/**
 * 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()}.
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
/**
 * Remove a previously installed global layout callback.
 * @param observer the view observer
 * @param victim the victim
 */
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static void removeOnGlobalLayoutListener(ViewTreeObserver observer, ViewTreeObserver.OnGlobalLayoutListener victim) {
    // Future (API16+)...
    if (Build.VERSION.SDK_INT >= 16) {
        observer.removeOnGlobalLayoutListener(victim);
    }
    // Legacy...
    else {
        observer.removeGlobalOnLayoutListener(victim);
    }
}
 
源代码9 项目: OmniList   文件: PhotoViewAttacher.java
/**
 * 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 View#onDetachedFromWindow()} or
 * from {@link android.app.Activity#onDestroy()}. This is automatically called if you are using
 * {@link PhotoView}.
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
源代码10 项目: MoeGallery   文件: PhotoViewAttacher.java
/**
 * 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 void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
源代码11 项目: ParallaxEverywhere   文件: PEWTextView.java
@Override
protected void onDetachedFromWindow() {
    ViewTreeObserver viewTreeObserver = getViewTreeObserver();
    viewTreeObserver.removeOnScrollChangedListener(mOnScrollChangedListener);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
    } else {
        viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
    }
    if (updateOnDraw
            && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnDrawListener(onDrawListener);
    }
    super.onDetachedFromWindow();
}
 
源代码12 项目: Scrollable   文件: ViewUtils.java
static void removeGlobalLayoutListener(View view, ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {

        final ViewTreeObserver observer = view.getViewTreeObserver();
        if (!observer.isAlive()) {
            return;
        }

        if (Build.VERSION.SDK_INT >= 16) {
            observer.removeOnGlobalLayoutListener(onGlobalLayoutListener);
        } else {
            //noinspection deprecation
            observer.removeGlobalOnLayoutListener(onGlobalLayoutListener);
        }
    }
 
源代码13 项目: CSipSimple   文件: ActivityChooserView.java
/**
 * 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;
}
 
源代码14 项目: TapTargetView   文件: ViewUtil.java
@SuppressWarnings("deprecation")
static void removeOnGlobalLayoutListener(ViewTreeObserver observer,
                                         ViewTreeObserver.OnGlobalLayoutListener listener) {
  if (Build.VERSION.SDK_INT >= 16) {
    observer.removeOnGlobalLayoutListener(listener);
  } else {
    observer.removeGlobalOnLayoutListener(listener);
  }
}
 
源代码15 项目: zen4android   文件: ActivityChooserView.java
/**
 * 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;
}
 
源代码16 项目: ZoomPreviewPicture   文件: PhotoViewAttacher.java
/**
 * 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.senab2.photoview2.PhotoView}.
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
/**
 * 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 void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
源代码18 项目: Album   文件: PhotoViewAttacher.java
/**
 * 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 View#onDetachedFromWindow()} or from {@link android.app.Activity#onDestroy()}. This
 * is automatically called if you are using {@link IPhotoView}.
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    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;
}
 
/**
 * 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;
}
 
源代码20 项目: Roid-Library   文件: RLAPICompat.java
/**
 * @param viewTreeObserver
 * @param onGlobalLayoutListener
 */
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver,
        OnGlobalLayoutListener onGlobalLayoutListener) {
    if (VERSION >= 16) {
        SDK16.removeGlobalLayoutListener(viewTreeObserver, onGlobalLayoutListener);
    } else {
        viewTreeObserver.removeGlobalOnLayoutListener(onGlobalLayoutListener);
    }
}