예제 #1
0
  private void updateSubviewClipStatus(View subview) {
    if (!mRemoveClippedSubviews || getParent() == null) {
      return;
    }

    Assertions.assertNotNull(mClippingRect);
    Assertions.assertNotNull(mAllChildren);

    // do fast check whether intersect state changed
    sHelperRect.set(subview.getLeft(), subview.getTop(), subview.getRight(), subview.getBottom());
    boolean intersects =
        mClippingRect.intersects(
            sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom);

    // If it was intersecting before, should be attached to the parent
    boolean oldIntersects = (subview.getParent() != null);

    if (intersects != oldIntersects) {
      int clippedSoFar = 0;
      for (int i = 0; i < mAllChildrenCount; i++) {
        if (mAllChildren[i] == subview) {
          updateSubviewClipStatus(mClippingRect, i, clippedSoFar);
          break;
        }
        if (mAllChildren[i].getParent() == null) {
          clippedSoFar++;
        }
      }
    }
  }
예제 #2
0
 private void updateClippingToRect(Rect clippingRect) {
   Assertions.assertNotNull(mAllChildren);
   int clippedSoFar = 0;
   for (int i = 0; i < mAllChildrenCount; i++) {
     updateSubviewClipStatus(clippingRect, i, clippedSoFar);
     if (mAllChildren[i].getParent() == null) {
       clippedSoFar++;
     }
   }
 }
예제 #3
0
 @Override
 public void onLayoutChange(
     View v,
     int left,
     int top,
     int right,
     int bottom,
     int oldLeft,
     int oldTop,
     int oldRight,
     int oldBottom) {
   if (mParent.getRemoveClippedSubviews()) {
     mParent.updateSubviewClipStatus(v);
   }
 }
예제 #4
0
 /*package*/ void addViewWithSubviewClippingEnabled(View child, int index, LayoutParams params) {
   Assertions.assertCondition(mRemoveClippedSubviews);
   Assertions.assertNotNull(mClippingRect);
   Assertions.assertNotNull(mAllChildren);
   addInArray(child, index);
   // we add view as "clipped" and then run {@link #updateSubviewClipStatus} to conditionally
   // attach it
   int clippedSoFar = 0;
   for (int i = 0; i < index; i++) {
     if (mAllChildren[i].getParent() == null) {
       clippedSoFar++;
     }
   }
   updateSubviewClipStatus(mClippingRect, index, clippedSoFar);
   child.addOnLayoutChangeListener(mChildrenLayoutChangeListener);
 }