Java Code Examples for android.view.ViewTreeObserver#removeOnGlobalLayoutListener()
The following examples show how to use
android.view.ViewTreeObserver#removeOnGlobalLayoutListener() .
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: ActivityChooserView.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { dataModel.unregisterObserver(mModelDataSetOberver); } ViewTreeObserver viewTreeObserver = getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener); } if (isShowingPopup()) { dismissPopup(); } mIsAttachedToWindow = false; }
Example 2
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 3
Source File: BorderView.java From AndroidTvDemo with Apache License 2.0 | 6 votes |
public void detachFrom(ViewGroup viewGroup) { try { if (viewGroup == mViewGroup) { ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver(); viewTreeObserver.removeOnGlobalFocusChangeListener(this); viewTreeObserver.removeOnScrollChangedListener(this); viewTreeObserver.removeOnGlobalLayoutListener(this); viewTreeObserver.removeOnTouchModeChangeListener(this); borderEffect.OnDetach(mView, viewGroup); } } catch (Exception ex) { ex.printStackTrace(); } }
Example 4
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 5
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 6
Source File: OnGlobalLayoutSingleListener.java From SlideUp-Android with MIT License | 5 votes |
@Override public final void onGlobalLayout() { ViewTreeObserver observer = mView.getViewTreeObserver(); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) { observer.removeGlobalOnLayoutListener(this); } else { observer.removeOnGlobalLayoutListener(this); } mRunnable.run(); }
Example 7
Source File: MetroViewBorderImpl.java From TVSample with Apache License 2.0 | 5 votes |
public void detachFrom(ViewGroup viewGroup) { try { if (viewGroup == mViewGroup) { ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver(); viewTreeObserver.removeOnGlobalFocusChangeListener(this); viewTreeObserver.removeOnScrollChangedListener(this); viewTreeObserver.removeOnGlobalLayoutListener(this); viewTreeObserver.removeOnTouchModeChangeListener(this); mMetroViewBorder.OnDetach(mView, viewGroup); } } catch (Exception ex) { ex.printStackTrace(); } }
Example 8
Source File: MetroViewBorderImpl.java From TVSample with Apache License 2.0 | 5 votes |
public void detachFrom(ViewGroup viewGroup) { try { if (viewGroup == mViewGroup) { ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();//获取view树的观察者 viewTreeObserver.removeOnGlobalFocusChangeListener(this);//通知全局性移除相应的listener viewTreeObserver.removeOnScrollChangedListener(this); viewTreeObserver.removeOnGlobalLayoutListener(this); viewTreeObserver.removeOnTouchModeChangeListener(this); mMetroViewBorder.OnDetach(mView, viewGroup); } } catch (Exception ex) { ex.printStackTrace(); } }
Example 9
Source File: BorderView.java From TvWidget with Apache License 2.0 | 5 votes |
public void detachFrom(ViewGroup viewGroup) { try { if (viewGroup == mViewGroup) { ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver(); viewTreeObserver.removeOnGlobalFocusChangeListener(this); viewTreeObserver.removeOnScrollChangedListener(this); viewTreeObserver.removeOnGlobalLayoutListener(this); viewTreeObserver.removeOnTouchModeChangeListener(this); borderEffect.OnDetach(mView, viewGroup); } } catch (Exception ex) { ex.printStackTrace(); } }
Example 10
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 11
Source File: MetroViewBorderImpl.java From LivePlayback with Apache License 2.0 | 5 votes |
public void detachFrom(ViewGroup viewGroup) { try { if (viewGroup == mViewGroup) { ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();//获取view树的观察者 viewTreeObserver.removeOnGlobalFocusChangeListener(this);//通知全局性移除相应的listener viewTreeObserver.removeOnScrollChangedListener(this); viewTreeObserver.removeOnGlobalLayoutListener(this); viewTreeObserver.removeOnTouchModeChangeListener(this); mMetroViewBorder.OnDetach(mView, viewGroup); } } catch (Exception ex) { ex.printStackTrace(); } }
Example 12
Source File: WorkWorldDetailsAdapter.java From imsdk-android with MIT License | 5 votes |
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private void removeGlobalOnLayoutListener(ViewTreeObserver obs, ViewTreeObserver.OnGlobalLayoutListener listener) { if (obs == null) return; if (Build.VERSION.SDK_INT < 16) { obs.removeGlobalOnLayoutListener(listener); } else { obs.removeOnGlobalLayoutListener(listener); } }
Example 13
Source File: ViewUtils.java From ListItemView with Apache License 2.0 | 5 votes |
public static void removeGlobalLayoutObserver(final ViewTreeObserver observer, ViewTreeObserver.OnGlobalLayoutListener layoutListener) { if (Build.VERSION.SDK_INT < 16) { observer.removeGlobalOnLayoutListener(layoutListener); } else { observer.removeOnGlobalLayoutListener(layoutListener); } }
Example 14
Source File: MizLib.java From Mizuu with Apache License 2.0 | 5 votes |
/** * Helper method to remove a ViewTreeObserver correctly, i.e. * avoiding the deprecated method on API level 16+. * @param vto * @param victim */ @SuppressWarnings("deprecation") public static void removeViewTreeObserver(ViewTreeObserver vto, OnGlobalLayoutListener victim) { if (MizLib.hasJellyBean()) { vto.removeOnGlobalLayoutListener(victim); } else { vto.removeGlobalOnLayoutListener(victim); } }
Example 15
Source File: PEWImageView.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 16
Source File: MaterialTapTargetPrompt.java From styT with Apache License 2.0 | 5 votes |
/** * Removes global layout listener added in {@link #addGlobalLayoutListener()}. */ void removeGlobalLayoutListener() { final ViewTreeObserver viewTreeObserver = mView.mPromptOptions.getResourceFinder().getPromptParentView().getViewTreeObserver(); if (viewTreeObserver.isAlive()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { viewTreeObserver.removeOnGlobalLayoutListener(mGlobalLayoutListener); } else { //noinspection deprecation viewTreeObserver.removeGlobalOnLayoutListener(mGlobalLayoutListener); } } }
Example 17
Source File: ViewUtil.java From styT with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") static void removeOnGlobalLayoutListener(ViewTreeObserver observer, ViewTreeObserver.OnGlobalLayoutListener listener) { observer.removeOnGlobalLayoutListener(listener); }
Example 18
Source File: FullscreenPopupWindow.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); ViewTreeObserver vto = mLayout.getViewTreeObserver(); vto.removeOnGlobalLayoutListener(this); }
Example 19
Source File: ApiTwentyOnePlus.java From Linphone4Android with GNU General Public License v3.0 | 4 votes |
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) { viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener); }
Example 20
Source File: PXHierarchyListener.java From pixate-freestyle-android with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void removeGlobalLayoutListenerJB(ViewTreeObserver observer, OnGlobalLayoutListener listener) { observer.removeOnGlobalLayoutListener(listener); }