void prepareForContainerRemoval() { containerFullyAttached = false; if (container != null) { container.setOnHierarchyChangeListener(null); } }
@Override public void onChildViewAdded(View parent, View child) { if (child instanceof WebView) { mChildrenNeedingAllTouches.add(child); } else if (child instanceof ViewGroup) { ViewGroup childGroup = (ViewGroup) child; childGroup.setOnHierarchyChangeListener(this); for (int i = 0, childCount = childGroup.getChildCount(); i < childCount; i++) { onChildViewAdded(childGroup, childGroup.getChildAt(i)); } } }
@Override public void onChildViewRemoved(View parent, View child) { if (child instanceof WebView) { mChildrenNeedingAllTouches.remove(child); } else if (child instanceof ViewGroup) { ViewGroup childGroup = (ViewGroup) child; for (int i = 0, childCount = childGroup.getChildCount(); i < childCount; i++) { onChildViewRemoved(childGroup, childGroup.getChildAt(i)); } childGroup.setOnHierarchyChangeListener(null); } } }
@Test public void removeAllViews_shouldCallOnChildViewRemovedWithEachChild() throws Exception { View view = new View(context); ViewGroup viewGroup = new FrameLayout(context); viewGroup.addView(view); TestOnHierarchyChangeListener testListener = new TestOnHierarchyChangeListener(); viewGroup.setOnHierarchyChangeListener(testListener); viewGroup.removeAllViews(); assertTrue(testListener.wasCalled()); }
@Override public void onChildViewAdded(View parent, View child) { delegate.onChildViewAdded(parent, child); if (child instanceof ViewGroup) { ViewGroup childGroup = (ViewGroup) child; childGroup.setOnHierarchyChangeListener(this); for (int i = 0; i < childGroup.getChildCount(); i++) { onChildViewAdded(childGroup, childGroup.getChildAt(i)); } } }
if (actionBarContainerChild instanceof ViewGroup && actionBarContainerChild.getClass().equals(actionBarViewClass)) { final ViewGroup actionBarView = (ViewGroup) actionBarContainerChild; actionBarView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() { @Override public void onChildViewAdded(final View parent, final View child) {
/** * Destroys the current {@link ContentViewCore}. * @param deleteNativeWebContents Whether or not to delete the native WebContents pointer. */ private final void destroyContentViewCore(boolean deleteNativeWebContents) { if (mContentViewCore == null) return; mContentViewCore.getContainerView().setOnHierarchyChangeListener(null); mContentViewCore.getContainerView().setOnSystemUiVisibilityChangeListener(null); if (mGestureStateListener != null) { mContentViewCore.removeGestureStateListener(mGestureStateListener); } if (mInfoBarContainer != null && mInfoBarContainer.getParent() != null) { mInfoBarContainer.removeFromParentView(); mInfoBarContainer.setContentViewCore(null); } if (mSwipeRefreshHandler != null) { mSwipeRefreshHandler.setContentViewCore(null); mSwipeRefreshHandler = null; } mContentViewParent = null; mContentViewCore.destroy(); mContentViewCore = null; mWebContentsDelegate = null; if (mWebContentsObserver != null) { mWebContentsObserver.destroy(); mWebContentsObserver = null; } assert mNativeTabAndroid != 0; nativeDestroyWebContents(mNativeTabAndroid, deleteNativeWebContents); }
cvc.getContainerView().setOnHierarchyChangeListener(this); cvc.getContainerView().setOnSystemUiVisibilityChangeListener(this);