Java Code Examples for android.view.ViewTreeObserver#removeGlobalOnLayoutListener()
The following examples show how to use
android.view.ViewTreeObserver#removeGlobalOnLayoutListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditState.java From sa-sdk-android with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: CropView.java From ImagePicker with Apache License 2.0 | 6 votes |
@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(); }
Example 3
Source File: RLAPICompat.java From Roid-Library with Apache License 2.0 | 5 votes |
/** * @param viewTreeObserver * @param onGlobalLayoutListener */ public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener onGlobalLayoutListener) { if (VERSION >= 16) { SDK16.removeGlobalLayoutListener(viewTreeObserver, onGlobalLayoutListener); } else { viewTreeObserver.removeGlobalOnLayoutListener(onGlobalLayoutListener); } }
Example 4
Source File: PhotoViewAttacher.java From Nimingban with Apache License 2.0 | 5 votes |
/** * 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; }
Example 5
Source File: ActivityChooserView.java From Libraries-for-Android-Developers with MIT License | 5 votes |
/** * 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; }
Example 6
Source File: PhotoViewAttacher.java From Album with Apache License 2.0 | 5 votes |
/** * 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; }
Example 7
Source File: PhotoViewAttacher.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 8
Source File: PhotoViewAttacher.java From ZoomPreviewPicture with Apache License 2.0 | 5 votes |
/** * 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; }
Example 9
Source File: ActivityChooserView.java From zen4android with MIT License | 5 votes |
/** * 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; }
Example 10
Source File: ViewUtil.java From TapTargetView with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") static void removeOnGlobalLayoutListener(ViewTreeObserver observer, ViewTreeObserver.OnGlobalLayoutListener listener) { if (Build.VERSION.SDK_INT >= 16) { observer.removeOnGlobalLayoutListener(listener); } else { observer.removeGlobalOnLayoutListener(listener); } }
Example 11
Source File: ActivityChooserView.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example 12
Source File: ViewUtils.java From Scrollable with Apache License 2.0 | 5 votes |
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); } }
Example 13
Source File: PEWTextView.java From ParallaxEverywhere with MIT License | 5 votes |
@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(); }
Example 14
Source File: PhotoViewAttacher.java From MoeGallery with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example 15
Source File: PhotoViewAttacher.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; }
Example 16
Source File: ViewTreeObserverCompat.java From android-signaturepad with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 17
Source File: ImageViewScaler.java From MultiView with Apache License 2.0 | 5 votes |
/** * 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; }
Example 18
Source File: PhotoViewAttacher.java From imsdk-android with MIT License | 5 votes |
/** * 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; }
Example 19
Source File: ActivityChooserView.java From zhangshangwuda with Apache License 2.0 | 5 votes |
/** * 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; }
Example 20
Source File: CropPhotoViewAttacher.java From ImageSelector with Apache License 2.0 | 5 votes |
/** * 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; }