List of usage examples for android.graphics Rect toShortString
public String toShortString()
From source file:android.support.design.widget.CoordinatorLayout.java
private void offsetChildByInset(final View child, final Rect inset, final int layoutDirection) { if (!ViewCompat.isLaidOut(child)) { // The view has not been laid out yet, so we can't obtain its bounds. return;/*from ww w . j a v a 2 s. c o m*/ } if (child.getWidth() <= 0 || child.getHeight() <= 0) { // Bounds are empty so there is nothing to dodge against, skip... return; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final Behavior behavior = lp.getBehavior(); final Rect dodgeRect = acquireTempRect(); final Rect bounds = acquireTempRect(); bounds.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); if (behavior != null && behavior.getInsetDodgeRect(this, child, dodgeRect)) { // Make sure that the rect is within the view's bounds if (!bounds.contains(dodgeRect)) { throw new IllegalArgumentException("Rect should be within the child's bounds." + " Rect:" + dodgeRect.toShortString() + " | Bounds:" + bounds.toShortString()); } } else { dodgeRect.set(bounds); } // We can release the bounds rect now releaseTempRect(bounds); if (dodgeRect.isEmpty()) { // Rect is empty so there is nothing to dodge against, skip... releaseTempRect(dodgeRect); return; } final int absDodgeInsetEdges = GravityCompat.getAbsoluteGravity(lp.dodgeInsetEdges, layoutDirection); boolean offsetY = false; if ((absDodgeInsetEdges & Gravity.TOP) == Gravity.TOP) { int distance = dodgeRect.top - lp.topMargin - lp.mInsetOffsetY; if (distance < inset.top) { setInsetOffsetY(child, inset.top - distance); offsetY = true; } } if ((absDodgeInsetEdges & Gravity.BOTTOM) == Gravity.BOTTOM) { int distance = getHeight() - dodgeRect.bottom - lp.bottomMargin + lp.mInsetOffsetY; if (distance < inset.bottom) { setInsetOffsetY(child, distance - inset.bottom); offsetY = true; } } if (!offsetY) { setInsetOffsetY(child, 0); } boolean offsetX = false; if ((absDodgeInsetEdges & Gravity.LEFT) == Gravity.LEFT) { int distance = dodgeRect.left - lp.leftMargin - lp.mInsetOffsetX; if (distance < inset.left) { setInsetOffsetX(child, inset.left - distance); offsetX = true; } } if ((absDodgeInsetEdges & Gravity.RIGHT) == Gravity.RIGHT) { int distance = getWidth() - dodgeRect.right - lp.rightMargin + lp.mInsetOffsetX; if (distance < inset.right) { setInsetOffsetX(child, distance - inset.right); offsetX = true; } } if (!offsetX) { setInsetOffsetX(child, 0); } releaseTempRect(dodgeRect); }