當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.getViewTreeObserver方法代碼示例

本文整理匯總了Java中android.widget.ImageView.getViewTreeObserver方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.getViewTreeObserver方法的具體用法?Java ImageView.getViewTreeObserver怎麽用?Java ImageView.getViewTreeObserver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.getViewTreeObserver方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPreDraw

import android.widget.ImageView; //導入方法依賴的package包/類
@Override public boolean onPreDraw() {
  ImageView target = this.target.get();
  if (target == null) {
    return true;
  }

  ViewTreeObserver vto = target.getViewTreeObserver();
  if (!vto.isAlive()) {
    return true;
  }

  int width = target.getWidth();
  int height = target.getHeight();

  if (width <= 0 || height <= 0 || target.isLayoutRequested()) {
    return true;
  }

  target.removeOnAttachStateChangeListener(this);
  vto.removeOnPreDrawListener(this);
  this.target.clear();

  this.creator.unfit().resize(width, height).into(target, callback);
  return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:DeferredRequestCreator.java

示例2: cancel

import android.widget.ImageView; //導入方法依賴的package包/類
void cancel() {
  creator.clearTag();
  callback = null;

  ImageView target = this.target.get();
  if (target == null) {
    return;
  }
  this.target.clear();

  target.removeOnAttachStateChangeListener(this);

  ViewTreeObserver vto = target.getViewTreeObserver();
  if (vto.isAlive()) {
    vto.removeOnPreDrawListener(this);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:DeferredRequestCreator.java

示例3: cleanup

import android.widget.ImageView; //導入方法依賴的package包/類
public void cleanup() {
    if(null != this.mImageView) {
        ImageView imageView = (ImageView)this.mImageView.get();
        if(null != imageView) {
            ViewTreeObserver observer = imageView.getViewTreeObserver();
            if(null != observer && observer.isAlive()) {
                observer.removeGlobalOnLayoutListener(this);
            }

            imageView.setOnTouchListener((View.OnTouchListener)null);
            this.cancelFling();
        }

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

        this.mMatrixChangeListener = null;
        this.mPhotoTapListener = null;
        this.mViewTapListener = null;
        this.mImageView = null;
    }
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:24,代碼來源:PhotoViewAttacher.java

示例4: cleanup

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:joelan,項目名稱:ClouldReader,代碼行數:41,代碼來源:PhotoViewAttacher.java

示例5: cleanup

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 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 opensource.component.photoview.PhotoView}.
 */
@SuppressWarnings("deprecation")
public final 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;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:41,代碼來源:PhotoViewAttacher.java

示例6: PhotoViewAttacher

import android.widget.ImageView; //導入方法依賴的package包/類
public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setOnTouchListener(this);

    mViewTreeObserver = imageView.getViewTreeObserver();
    mViewTreeObserver.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (!imageView.isInEditMode()) {
        // Create Gesture Detectors...
        mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

        mGestureDetector = new GestureDetector(imageView.getContext(),
                new GestureDetector.SimpleOnGestureListener() {

                    // forward long click listener
                    @Override
                    public void onLongPress(MotionEvent e) {
                        if (null != mLongClickListener) {
                            mLongClickListener.onLongClick(mImageView.get());
                        }
                    }
                });

        mGestureDetector.setOnDoubleTapListener(this);

        // Finally, update the UI so that we're zoomable
        setZoomable(true);
    }
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:34,代碼來源:PhotoViewAttacher.java

示例7: cleanup

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:40,代碼來源:PhotoViewAttacher.java

示例8: PhotoViewAttacher

import android.widget.ImageView; //導入方法依賴的package包/類
public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

    // Finally, update the UI so that we're zoomable
    setZoomable(true);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:38,代碼來源:PhotoViewAttacher.java

示例9: cleanup

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:WeiXinqiao,項目名稱:Recognize-it,代碼行數:41,代碼來源:PhotoViewAttacher.java

示例10: cleanup

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:41,代碼來源:PhotoViewAttacher.java

示例11: onLayoutSkipsIfTargetIsNullAfterAttach

import android.widget.ImageView; //導入方法依賴的package包/類
@Test public void onLayoutSkipsIfTargetIsNullAfterAttach() {
  ImageView target = mockFitImageViewTarget(true);
  RequestCreator creator = mock(RequestCreator.class);
  DeferredRequestCreator request = new DeferredRequestCreator(creator, target, null);
  ViewTreeObserver viewTreeObserver = target.getViewTreeObserver();
  request.target.clear();
  request.onPreDraw();
  verifyZeroInteractions(creator);
  verify(viewTreeObserver).addOnPreDrawListener(request);
  verifyNoMoreInteractions(viewTreeObserver);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:DeferredRequestCreatorTest.java

示例12: PhotoViewAttacher

import android.widget.ImageView; //導入方法依賴的package包/類
public PhotoViewAttacher(ImageView imageView) {
	mImageView = new WeakReference<ImageView>(imageView);

	imageView.setOnTouchListener(this);

	mViewTreeObserver = imageView.getViewTreeObserver();
	mViewTreeObserver.addOnGlobalLayoutListener(this);

	// Make sure we using MATRIX Scale Type
	setImageViewScaleTypeMatrix(imageView);

	if (!imageView.isInEditMode()) {
		// Create Gesture Detectors...
		mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

		mGestureDetector = new GestureDetector(imageView.getContext(),
				new GestureDetector.SimpleOnGestureListener() {

					// forward long click listener
					@Override
					public void onLongPress(MotionEvent e) {
						if(null != mLongClickListener) {
							mLongClickListener.onLongClick(mImageView.get());
						}
					}});

		mGestureDetector.setOnDoubleTapListener(this);

		// Finally, update the UI so that we're zoomable
		setZoomable(true);
	}
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:33,代碼來源:PhotoViewAttacher.java

示例13: into

import android.widget.ImageView; //導入方法依賴的package包/類
public void into(final ImageView target) {
    ViewTreeObserver viewTreeObserver = target.getViewTreeObserver();
    viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        public boolean onPreDraw() {
            target.getViewTreeObserver().removeOnPreDrawListener(this);

            new ImageLoaderThread(target, url).start();

            return true;
        }
    });
}
 
開發者ID:florent37,項目名稱:CameraFragment,代碼行數:13,代碼來源:ImageLoader.java

示例14: PhotoViewAttacher

import android.widget.ImageView; //導入方法依賴的package包/類
public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setOnTouchListener(this);

    mViewTreeObserver = imageView.getViewTreeObserver();
    mViewTreeObserver.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (!imageView.isInEditMode()) {
        // Create Gesture Detectors...
        mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

        mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() {

            // forward long click listener
            @Override
            public void onLongPress(MotionEvent e) {
                if (null != mLongClickListener) {
                    mLongClickListener.onLongClick(mImageView.get());
                }
            }
        });

        mGestureDetector.setOnDoubleTapListener(this);

        // Finally, addOrUpdate the UI so that we're zoomable
        setZoomable(true);
    }
}
 
開發者ID:liuke2016,項目名稱:filepicker,代碼行數:33,代碼來源:PhotoViewAttacher.java

示例15: PhotoViewAttacher

import android.widget.ImageView; //導入方法依賴的package包/類
public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

    // Finally, update the UI so that we're zoomable
    setZoomable(true);
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:37,代碼來源:PhotoViewAttacher.java


注:本文中的android.widget.ImageView.getViewTreeObserver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。