List of usage examples for android.view ViewTreeObserver removeGlobalOnLayoutListener
@Deprecated public void removeGlobalOnLayoutListener(OnGlobalLayoutListener victim)
From source file:edu.usf.cutr.opentripplanner.android.fragments.MainFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void removeOnGlobalLayoutListener(View v, ViewTreeObserver.OnGlobalLayoutListener listener) { ViewTreeObserver viewTreeObserver = v.getViewTreeObserver(); if (viewTreeObserver != null) { if (Build.VERSION.SDK_INT < 16) { viewTreeObserver.removeGlobalOnLayoutListener(listener); } else {/*from ww w. ja v a 2s .c o m*/ viewTreeObserver.removeOnGlobalLayoutListener(listener); } } else { Log.w(OTPApp.TAG, "Problems obtaining exact element's positions on screen, some other elements" + "can be misplaced"); } }
From source file:com.androzic.MapActivity.java
private void updateMapViewArea() { final ViewTreeObserver vto = map.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { public void onGlobalLayout() { Rect area = new Rect(); map.getLocalVisibleRect(area); View v = findViewById(R.id.topbar); if (v != null) area.top = v.getBottom(); v = findViewById(R.id.bottombar); if (v != null) area.bottom = v.getTop(); v = findViewById(R.id.rightbar); if (v != null) area.right = v.getLeft(); if (!area.isEmpty()) map.updateViewArea(area); if (vto.isAlive()) { vto.removeGlobalOnLayoutListener(this); } else { final ViewTreeObserver vto1 = map.getViewTreeObserver(); vto1.removeGlobalOnLayoutListener(this); }/* w ww . ja v a 2s .c om*/ } }); }
From source file:com.example.libwidgettv.bak.AbsListView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); // Dismiss the popup in case onSaveInstanceState() was not invoked dismissPopup();/* w ww.j a v a 2 s . co m*/ // Detach any view left in the scrap heap mRecycler.clear(); final ViewTreeObserver treeObserver = getViewTreeObserver(); treeObserver.removeOnTouchModeChangeListener(this); if (mTextFilterEnabled && mPopup != null) { treeObserver.removeGlobalOnLayoutListener(this); mGlobalLayoutListenerAddedFilter = false; } if (mAdapter != null) { mAdapter.unregisterDataSetObserver(mDataSetObserver); mDataSetObserver = null; } if (mFlingRunnable != null) { removeCallbacks(mFlingRunnable); } if (mPositionScroller != null) { mPositionScroller.stop(); } if (mClearScrollingCache != null) { removeCallbacks(mClearScrollingCache); } if (mPerformClick != null) { removeCallbacks(mPerformClick); } if (mTouchModeReset != null) { removeCallbacks(mTouchModeReset); mTouchModeReset = null; } mIsAttached = false; }
From source file:com.common.widget.hzlib.AbsHorizontalListView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); // Dismiss the popup in case onSaveInstanceState() was not invoked dismissPopup();//from w w w . j a v a2 s .com // Detach any view left in the scrap heap mRecycler.clear(); final ViewTreeObserver treeObserver = getViewTreeObserver(); treeObserver.removeOnTouchModeChangeListener(this); if (mTextFilterEnabled && mPopup != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { treeObserver.removeOnGlobalLayoutListener(this); } else { treeObserver.removeGlobalOnLayoutListener(this); } mGlobalLayoutListenerAddedFilter = false; } if (mAdapter != null) { mAdapter.unregisterDataSetObserver(mDataSetObserver); mDataSetObserver = null; } // TODO we removed strict span in backport (j.m.) //if (mScrollStrictSpan != null) { // mScrollStrictSpan.finish(); // mScrollStrictSpan = null; //} //if (mFlingStrictSpan != null) { // mFlingStrictSpan.finish(); // mFlingStrictSpan = null; //} if (mFlingRunnable != null) { removeCallbacks(mFlingRunnable); } if (mPositionScroller != null) { mPositionScroller.stop(); } if (mClearScrollingCache != null) { removeCallbacks(mClearScrollingCache); } if (mPerformClick != null) { removeCallbacks(mPerformClick); } if (mTouchModeReset != null) { removeCallbacks(mTouchModeReset); mTouchModeReset.run(); } }