protected void updateDrawable(Drawable newDrawable) { if (null != newDrawable) { mBitmapRect.set(0, 0, newDrawable.getIntrinsicWidth(), newDrawable.getIntrinsicHeight()); } else { mBitmapRect.setEmpty(); } }
@Override public void clipView(@Nullable RectF rect, float rotation) { if (rect == null) { clipRect.setEmpty(); } else { clipRect.set(rect); } clipRotation = rotation; updateShaderMatrix(); super.clipView(rect, rotation); }
@ThreadSafe(enableChecks = false) static void releaseRectF(RectF rect) { if (ComponentsConfiguration.disablePools) { return; } rect.setEmpty(); sRectFPool.release(rect); }
private IDanmakus touchHitDanmaku(final float x, final float y) { final IDanmakus hitDanmakus = new Danmakus(); mDanmakuBounds.setEmpty(); IDanmakus danmakus = danmakuView.getCurrentVisibleDanmakus(); if (null != danmakus && !danmakus.isEmpty()) { danmakus.forEachSync(new IDanmakus.DefaultConsumer<BaseDanmaku>() { @Override public int accept(BaseDanmaku danmaku) { if (null != danmaku) { mDanmakuBounds.set(danmaku.getLeft(), danmaku.getTop(), danmaku.getRight(), danmaku.getBottom()); if (mDanmakuBounds.intersect(x - mXOff, y - mYOff, x + mXOff, y + mYOff)) { hitDanmakus.addItem(danmaku); } } return ACTION_CONTINUE; } }); } return hitDanmakus; } }
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; } }
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; } }
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; } }
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; } }
/** * @param rect The area that events should be stolen from in dp. */ public void setEventArea(RectF rect) { if (rect == null) { mTriggerRect.setEmpty(); } else { mTriggerRect.set(rect); } }
protected void mapPhotoRect(RectF src, RectF dst) { if (photoBounds.isEmpty()) { dst.setEmpty(); } else { photoMatrix.mapRect(dst, src); dst.set(dst.left / photoBounds.width(), dst.top / photoBounds.height(), dst.right / photoBounds.width(), dst.bottom / photoBounds.height()); } } }
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mSticky != null) { final int saveCount = canvas.save(); // The view to draw when sticking to the top final View drawTarget = mStickyContainer != null ? mStickyContainer : mSticky; // The offset to draw the view at when sticky final int drawOffset = mStickyContainer != null ? mSticky.getTop() : 0; // Position of the draw target, relative to the outside of the scrollView final int drawTop = drawTarget.getTop(); if (drawTop + drawOffset < mStatusBarInset || !drawTarget.isShown()) { // ListView does not translate the canvas, so we can simply draw at the top mStickyRect.set(0, -drawOffset + mStatusBarInset, drawTarget.getWidth(), drawTarget.getHeight() - drawOffset + mStatusBarInset); canvas.translate(0, mStickyRect.top); canvas.clipRect(0, 0, drawTarget.getWidth(), drawTarget.getHeight()); drawTarget.draw(canvas); } else { mStickyRect.setEmpty(); } canvas.restoreToCount(saveCount); } }
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mSticky != null) { final View headerView = getHeader(); final int saveCount = canvas.save(); // The view to draw when sticking to the top final View drawTarget = headerView != null ? headerView : mSticky; // The offset to draw the view at when sticky final int drawOffset = headerView != null ? mSticky.getTop() : 0; // Position of the draw target, relative to the outside of the scrollView final int drawTop = drawTarget.getTop(); if (drawTop + drawOffset < mStatusBarInset || !drawTarget.isShown()) { // RecyclerView does not translate the canvas, so we can simply draw at the top mStickyRect.set(0, -drawOffset + mStatusBarInset, drawTarget.getWidth(), drawTarget.getHeight() - drawOffset + mStatusBarInset); canvas.translate(0, mStickyRect.top); canvas.clipRect(0, 0, drawTarget.getWidth(), drawTarget.getHeight()); drawTarget.draw(canvas); } else { mStickyRect.setEmpty(); } canvas.restoreToCount(saveCount); } }
private void drawStrokeLine(Canvas canvas) { if (strokeWidth > 0) { if (strokeWidthPath == null) { strokeWidthPath = new Path(); } else { strokeWidthPath.reset(); } if (strokeLineRectF == null) { strokeLineRectF = new RectF(); } else { strokeLineRectF.setEmpty(); } strokeLineRectF.set(strokeWidth / 2, strokeWidth / 2, width - strokeWidth / 2, height - strokeWidth / 2); getCorners(corner); strokeWidthPath.addRoundRect(strokeLineRectF, corners, Path.Direction.CW); initPaint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(strokeColor); paint.setStrokeWidth(strokeWidth); canvas.drawPath(strokeWidthPath, paint); } }
private void drawStrokeLine(Canvas canvas) { if (strokeWidth > 0) { if (strokeWidthPath == null) { strokeWidthPath = new Path(); } else { strokeWidthPath.reset(); } if (strokeLineRectF == null) { strokeLineRectF = new RectF(); } else { strokeLineRectF.setEmpty(); } strokeLineRectF.set(strokeWidth / 2, strokeWidth / 2, width - strokeWidth / 2, height - strokeWidth / 2); getCorners(corner); strokeWidthPath.addRoundRect(strokeLineRectF, corners, Path.Direction.CW); initPaint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(strokeColor); paint.setStrokeWidth(strokeWidth); canvas.drawPath(strokeWidthPath, paint); } }
private void drawSolid(Canvas canvas) { if (solidPath == null) { solidPath = new Path(); } else { solidPath.reset(); } if (solidRectF == null) { solidRectF = new RectF(); } else { solidRectF.setEmpty(); } solidRectF.set(strokeWidth, strokeWidth, width - strokeWidth, height - strokeWidth); getCorners(corner - strokeWidth / 2); solidPath.addRoundRect(solidRectF, corners, Path.Direction.CW); initPaint(); paint.setStyle(Paint.Style.FILL); if (shaderEnable) { useShader(paint); } else { paint.setColor(solid); } canvas.drawPath(solidPath, paint); }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); displayBounds.setEmpty(); photoMatrix.reset(); if (photoBounds.isEmpty()) { return; } // Assumes photo-view is also full-screen as this tool-view and centers/scales photo to fit. Matrix matrix = new Matrix(); if (matrix.setRectToRect(photoBounds, new RectF(0, 0, w, h), Matrix.ScaleToFit.CENTER)) { matrix.mapRect(displayBounds, photoBounds); } matrix.invert(photoMatrix); }
private void drawSolid(Canvas canvas) { if (solidPath == null) { solidPath = new Path(); } else { solidPath.reset(); } if (solidRectF == null) { solidRectF = new RectF(); } else { solidRectF.setEmpty(); } solidRectF.set(strokeWidth, strokeWidth, width - strokeWidth, height - strokeWidth); getCorners(corner - strokeWidth / 2); solidPath.addRoundRect(solidRectF, corners, Path.Direction.CW); initPaint(); paint.setStyle(Paint.Style.FILL); if (shaderEnable) { useShader(paint); } else { paint.setColor(solid); } canvas.drawPath(solidPath, paint); }
@Override public void getTouchBound(ScrollbarRecyclerView view, RectF bound, int slop) { if (mAnimatorValue == 0 && !mAlwaysTouchable) { bound.setEmpty(); return; } if (mTouchStartOnBar) { bound.set(view.getPaddingLeft() + mPaddingStart - slop, mSliderBound.top - slop, view.getWidth() - view.getPaddingRight() - mPaddingEnd + slop, mSliderBound.bottom + slop); } else { bound.set(mSliderBound.left - slop, mSliderBound.top - slop, mSliderBound.right + slop, mSliderBound.bottom + slop); } }
@Override public void getTouchBound(ScrollbarRecyclerView view, RectF bound, int slop) { if (mAnimatorValue == 0 && !mAlwaysTouchable) { bound.setEmpty(); return; } if (mTouchStartOnBar) { bound.set(mSliderBound.left - slop, view.getPaddingTop() + mPaddingStart - slop, mSliderBound.right + slop, view.getHeight() - view.getPaddingBottom() - mPaddingEnd + slop); } else { bound.set(mSliderBound.left - slop, mSliderBound.top - slop, mSliderBound.right + slop, mSliderBound.bottom + slop); } }
final float y = event.getY(); if (action == MotionEvent.ACTION_DOWN) { mPress.setEmpty(); mPoints.clear(); mPress.set(x, y, x, y);