List of usage examples for android.view ViewTreeObserver isAlive
public boolean isAlive()
From source file:com.androzic.vnspeech.MapFragment.java
private void updateMapViewArea() { final ViewTreeObserver vto = map.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") public void onGlobalLayout() { View root = getView(); Rect area = new Rect(); map.getLocalVisibleRect(area); View v = root.findViewById(R.id.topbar); if (v != null) area.top = v.getBottom(); v = root.findViewById(R.id.bottombar); if (v != null) area.bottom = v.getTop(); if (mapLicense.isShown()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && mapLicense.getRotation() != 0f) area.left = mapLicense.getHeight(); // rotated view does not correctly report it's position else area.bottom = mapLicense.getTop(); }// ww w.j a v a 2 s .com v = root.findViewById(R.id.rightbar); if (v != null) area.right = v.getLeft(); if (mapButtons.isShown()) { // Landscape mode if (v != null) area.bottom = mapButtons.getTop(); else area.right = mapButtons.getLeft(); } if (!area.isEmpty()) map.updateViewArea(area); ViewTreeObserver ob; if (vto.isAlive()) ob = vto; else ob = map.getViewTreeObserver(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { ob.removeGlobalOnLayoutListener(this); } else { ob.removeOnGlobalLayoutListener(this); } } }); }
From source file:org.mozilla.gecko.BrowserApp.java
private void showTabs(final TabsPanel.Panel panel) { if (Tabs.getInstance().getDisplayCount() == 0) return;/* w w w. j a v a 2 s . com*/ if (ensureTabsPanelExists()) { // If we've just inflated the tabs panel, only show it once the current // layout pass is done to avoid displayed temporary UI states during // relayout. ViewTreeObserver vto = mTabsPanel.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mTabsPanel.getViewTreeObserver().removeGlobalOnLayoutListener(this); showTabs(panel); } }); } } else { if (mDoorHangerPopup != null) { mDoorHangerPopup.disable(); } mTabsPanel.show(panel); // Hide potentially visible "find in page" bar (Bug 1177338) mFindInPageBar.hide(); } }