Java Code Examples for android.graphics.Rect#union()

The following examples show how to use android.graphics.Rect#union() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagerTabStrip.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: HighlightView.java    From reader with MIT License 6 votes vote down vote up
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);
}
 
Example 3
Source File: HighlightView.java    From YiBo with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: PagerTabStrip.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 5
Source File: HighlightView.java    From GalleryFinal with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 6
Source File: HighlightView.java    From memoir with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 7
Source File: HighlightView.java    From memoir with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 8
Source File: HighlightView.java    From HaiNaBaiChuan with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 9
Source File: HighlightView.java    From CloudPan with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 10
Source File: HighlightView.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 11
Source File: HighlightView.java    From WifiChat with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 12
Source File: PagerTabStrip.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@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);
}
 
Example 13
Source File: HighlightView.java    From XERUNG with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 14
Source File: HighlightView.java    From XERUNG with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 15
Source File: HighlightView.java    From bither-android with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 16
Source File: PagerTabStrip.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example 17
Source File: HighlightView.java    From LockDemo with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 18
Source File: RippleDrawableICS.java    From Carbon with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 19
Source File: RippleDrawable.java    From RippleDrawable with MIT License 5 votes vote down vote up
@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();
    }
}
 
Example 20
Source File: RangeStyle.java    From vlayout with MIT License 4 votes vote down vote up
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);
        }
    }
}