当前位置: 首页>>代码示例>>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;未经允许,请勿转载。