下面列出了android.graphics.Rect#union ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
@Override
void updateTextPositions(int position, float positionOffset, boolean force) {
final Rect r = mTempRect;
int bottom = getHeight();
int left = mCurrText.getLeft() - mTabPadding;
int right = mCurrText.getRight() + mTabPadding;
int top = bottom - mIndicatorHeight;
r.set(left, top, right, bottom);
super.updateTextPositions(position, positionOffset, force);
mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);
left = mCurrText.getLeft() - mTabPadding;
right = mCurrText.getRight() + mTabPadding;
r.union(left, top, right, bottom);
invalidate(r);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
mContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
@Override
void updateTextPositions(int position, float positionOffset, boolean force) {
final Rect r = mTempRect;
int bottom = getHeight();
int left = mCurrText.getLeft() - mTabPadding;
int right = mCurrText.getRight() + mTabPadding;
int top = bottom - mIndicatorHeight;
r.set(left, top, right, bottom);
super.updateTextPositions(position, positionOffset, force);
mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);
left = mCurrText.getLeft() - mTabPadding;
right = mCurrText.getRight() + mTabPadding;
r.union(left, top, right, bottom);
invalidate(r);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
// mContext.invalidate(invalRect);
mContext.invalidate();
}
@Override
void updateTextPositions(int position, float positionOffset, boolean force) {
final Rect r = mTempRect;
int bottom = getHeight();
int left = mCurrText.getLeft() - mTabPadding;
int right = mCurrText.getRight() + mTabPadding;
int top = bottom - mIndicatorHeight;
r.set(left, top, right, bottom);
super.updateTextPositions(position, positionOffset, force);
mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);
left = mCurrText.getLeft() - mTabPadding;
right = mCurrText.getRight() + mTabPadding;
r.union(left, top, right, bottom);
invalidate(r);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
mContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
mContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(drawRect);
cropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle
cropRect.offset(
Math.max(0, imageRect.left - cropRect.left),
Math.max(0, imageRect.top - cropRect.top));
cropRect.offset(
Math.min(0, imageRect.right - cropRect.right),
Math.min(0, imageRect.bottom - cropRect.bottom));
drawRect = computeLayout();
invalRect.union(drawRect);
invalRect.inset(-(int) handleRadius, -(int) handleRadius);
viewContext.invalidate(invalRect);
}
@Override
void updateTextPositions(int position, float positionOffset, boolean force) {
final Rect r = mTempRect;
int bottom = getHeight();
int left = mCurrText.getLeft() - mTabPadding;
int right = mCurrText.getRight() + mTabPadding;
int top = bottom - mIndicatorHeight;
r.set(left, top, right, bottom);
super.updateTextPositions(position, positionOffset, force);
mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);
left = mCurrText.getLeft() - mTabPadding;
right = mCurrText.getRight() + mTabPadding;
r.union(left, top, right, bottom);
invalidate(r);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(
Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(
Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
mContext.invalidate(invalRect);
}
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(
Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(
Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
mContext.invalidate(invalRect);
}
@Override
public Rect getDirtyBounds() {
if (isProjected()) {
final Rect drawingBounds = mDrawingBounds;
final Rect dirtyBounds = mDirtyBounds;
dirtyBounds.set(drawingBounds);
drawingBounds.setEmpty();
final int cX = (int) mHotspotBounds.exactCenterX();
final int cY = (int) mHotspotBounds.exactCenterY();
final Rect rippleBounds = mTempRect;
final Ripple[] activeRipples = mExitingRipples;
final int N = mExitingRipplesCount;
for (int i = 0; i < N; i++) {
activeRipples[i].getBounds(rippleBounds);
rippleBounds.offset(cX, cY);
drawingBounds.union(rippleBounds);
}
final RippleBackground background = mBackground;
if (background != null) {
background.getBounds(rippleBounds);
rippleBounds.offset(cX, cY);
drawingBounds.union(rippleBounds);
}
dirtyBounds.union(drawingBounds);
dirtyBounds.union(super.getDirtyBounds());
return dirtyBounds;
} else {
return getBounds();
}
}
@Override
public Rect getDirtyBounds() {
if (!isBounded()) {
final Rect drawingBounds = mDrawingBounds;
final Rect dirtyBounds = mDirtyBounds;
dirtyBounds.set(drawingBounds);
drawingBounds.setEmpty();
final int cX = (int) mHotspotBounds.exactCenterX();
final int cY = (int) mHotspotBounds.exactCenterY();
final Rect rippleBounds = mTempRect;
final RippleForeground[] activeRipples = mExitingRipples;
final int N = mExitingRipplesCount;
for (int i = 0; i < N; i++) {
activeRipples[i].getBounds(rippleBounds);
rippleBounds.offset(cX, cY);
drawingBounds.union(rippleBounds);
}
final RippleBackground background = mBackground;
if (background != null) {
background.getBounds(rippleBounds);
rippleBounds.offset(cX, cY);
drawingBounds.union(rippleBounds);
}
dirtyBounds.union(drawingBounds);
if (Build.VERSION.SDK_INT >= 21)
dirtyBounds.union(super.getDirtyBounds());
return dirtyBounds;
} else {
return getBounds();
}
}
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
if (!isChildrenEmpty()) {
for (Map.Entry<Range<Integer>, T> entry : mChildren.entrySet()) {
RangeStyle rangeStyle = entry.getValue();
rangeStyle.adjustLayout(startPosition, endPosition, helper);
}
}
if (requireLayoutView()) {
View refer = null;
Rect tempRect = new Rect();
final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
for (int i = 0; i < helper.getChildCount(); i++) {
refer = helper.getChildAt(i);
int anchorPos = helper.getPosition(refer);
if (getRange().contains(anchorPos)) {
if (refer.getVisibility() == View.GONE) {
tempRect.setEmpty();
} else {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
refer.getLayoutParams();
if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
orientationHelper.getDecoratedStart(refer),
helper.getDecoratedRight(refer) + params.rightMargin,
orientationHelper.getDecoratedEnd(refer));
} else {
tempRect.union(orientationHelper.getDecoratedStart(refer),
helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
helper.getDecoratedBottom(refer) + params.bottomMargin);
}
}
}
}
if (!tempRect.isEmpty()) {
mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
} else {
mLayoutRegion.setEmpty();
}
if (mLayoutView != null) {
mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
}
}
}