Esempio n. 1
0
 private void removeObserverForView(final View view) {
   final ViewTreeObserver treeObserver = view.getViewTreeObserver();
   if (treeObserver != null && treeObserver.isAlive()) {
     if (TiC.JELLY_BEAN_OR_GREATER) {
       treeObserver.removeOnGlobalLayoutListener(this);
     } else {
       treeObserver.removeGlobalOnLayoutListener(this);
     }
   }
 }
Esempio n. 2
0
 /** 删除监听器 */
 @SuppressWarnings("deprecation")
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
 public static final void removeOnGlobalLayoutListener(
     ViewTreeObserver viewTreeObserver,
     ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
   if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
     viewTreeObserver.removeGlobalOnLayoutListener(onGlobalLayoutListener);
   } else {
     viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener);
   }
 }
  /**
   * 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
   * EasePhotoView.co.senab.photoview.PhotoView}.
   */
  @SuppressLint("NewApi")
  @SuppressWarnings("deprecation")
  public final void cleanup() {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
      if (null != mImageView) {
        mImageView.get().getViewTreeObserver().removeOnGlobalLayoutListener(this);
      }

      if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {
        mViewTreeObserver.removeOnGlobalLayoutListener(this);

        mViewTreeObserver = null;

        // Clear listeners too
        mMatrixChangeListener = null;
        mPhotoTapListener = null;
        mViewTapListener = null;
        // Finally, clear ImageView
        mImageView = null;
      }

    } else {
      if (null != mImageView) {
        mImageView.get().getViewTreeObserver().removeGlobalOnLayoutListener(this);
      }

      if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {
        mViewTreeObserver.removeGlobalOnLayoutListener(this);

        mViewTreeObserver = null;

        // Clear listeners too
        mMatrixChangeListener = null;
        mPhotoTapListener = null;
        mViewTapListener = null;
        // Finally, clear ImageView
        mImageView = null;
      }
    }
  }
Esempio n. 4
0
 @Override
 public void removeOnGlobalLayoutListener(
     final ViewTreeObserver observer, final ViewTreeObserver.OnGlobalLayoutListener listener) {
   observer.removeOnGlobalLayoutListener(listener);
 }