@Override public Rect onGetEpicenter(Transition transition) { if (toEpicenter.isEmpty()) { return null; } return toEpicenter; } });
@Nullable Rect getExpandedTouchBounds() { if (mExpandedTouchBounds == null || mExpandedTouchBounds.isEmpty()) { return null; } return mExpandedTouchBounds; }
private static int computeRectArea(Rect rect) { return rect.isEmpty() ? 0 : (rect.width() * rect.height()); }
protected void drawSelectorCompat(Canvas canvas) { if (!mSelectorRect.isEmpty()) { final Drawable selector = getSelector(); if (selector != null) { selector.setBounds(mSelectorRect); selector.draw(canvas); } } } /**
private void drawSelector(Canvas canvas) { if (shouldShowSelector() && mSelectorRect != null && !mSelectorRect.isEmpty()) { final Drawable selector = mSelector; selector.setBounds(mSelectorRect); selector.draw(canvas); } }
@Override public void draw(Canvas canvas) { if (null != mBitmap && !mBitmap.isRecycled()) { final Rect bounds = getBounds(); if (!bounds.isEmpty()) { canvas.drawBitmap(mBitmap, null, bounds, mPaint); } else { canvas.drawBitmap(mBitmap, 0f, 0f, mPaint); } } }
public static Bitmap asBitmap(Drawable drawable, int minWidth, int minHeight) { final Rect tmpRect = new Rect(); drawable.copyBounds(tmpRect); if (tmpRect.isEmpty()) { tmpRect.set(0, 0, Math.max(minWidth, drawable.getIntrinsicWidth()), Math.max(minHeight, drawable.getIntrinsicHeight())); drawable.setBounds(tmpRect); } Bitmap bitmap = Bitmap.createBitmap(tmpRect.width(), tmpRect.height(), Bitmap.Config.ARGB_8888); drawable.draw(new Canvas(bitmap)); return bitmap; }
@Override public void draw(@NonNull Canvas canvas) { Rect bounds = getBounds(); if (!bounds.isEmpty()) { // Draw background backgroundPaint.setColor(backgroundColor); canvas.drawRect(bounds, backgroundPaint); if (!TextUtils.isEmpty(text)) { // Draw text updateTextSizeIfDirty(bounds); textPaint.setColor(textColor); canvas.drawText(text, x, y, textPaint); } } }
private void ensureExpandedTexture() { if (mExpandedTitleTexture != null || mExpandedBounds.isEmpty() || TextUtils.isEmpty(mTextToDraw)) { return; } mTextPaint.setTextSize(mExpandedTextSize); mTextPaint.setColor(mExpandedTextColor); mTextureAscent = mTextPaint.ascent(); mTextureDescent = mTextPaint.descent(); final int w = Math.round(mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length())); final int h = Math.round(mTextureDescent - mTextureAscent); if (w <= 0 && h <= 0) { return; // If the width or height are 0, return } mExpandedTitleTexture = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(mExpandedTitleTexture); c.drawText(mTextToDraw, 0, mTextToDraw.length(), 0, h - mTextPaint.descent(), mTextPaint); if (mTexturePaint == null) { // Make sure we have a paint mTexturePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); } }
public RectAssert isNotEmpty() { isNotNull(); assertThat(actual.isEmpty()) // .overridingErrorMessage("Expected to not be empty but was.") // .isFalse(); return this; }
public RectAssert isEmpty() { isNotNull(); assertThat(actual.isEmpty()) // .overridingErrorMessage("Expected to be empty but was not.") // .isTrue(); return this; }
@Override public void draw(Canvas canvas) { if (!getBounds().isEmpty()) { this.mLoadingRender.draw(canvas); } }
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); if (!mCustomMarkSize) { initIntrinsic(); } if (bounds.isEmpty()) return; mCenterX = bounds.centerX(); mCenterY = bounds.centerY(); int minCenter = Math.min(bounds.width(), bounds.height()) >> 1; int areRadius = minCenter - ((mBorderSize + 1) >> 1); mOval.set(mCenterX - areRadius, mCenterY - areRadius, mCenterX + areRadius, mCenterY + areRadius); mCircleRadius = minCenter - mBorderSize - mIntervalSize; }
private void updateWindow(boolean force, boolean redrawNeeded) { if (lock) { return; } long c = SystemClock.uptimeMillis(); if (c - time < 16) { return; } time = c; getLocationInWindow(tempLocationInWindow); final boolean visibleChanged = mVisible != mRequestedVisible; if (force || visibleChanged || tempLocationInWindow[0] != mLocation[0] || tempLocationInWindow[1] != mLocation[1] || redrawNeeded) { this.mLocation[0] = tempLocationInWindow[0]; this.mLocation[1] = tempLocationInWindow[1]; getVisibilityRect(tempVisibilityRect); if (!mVisibilityRect.equals(tempVisibilityRect)) { if (!(mVisibilityRect.isEmpty() && tempVisibilityRect.isEmpty())) { this.mVisibilityRect.set(tempVisibilityRect); onUpdateWindow(mVisibilityRect); } } } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Rect rect = mRect; rect.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); if (!rect.isEmpty()) { canvas.drawRect(rect, mPaint); } } }
@Override void highlightView(View view, Rect bounds, int mainColor) { mMainHighlightDrawable.setColor(mainColor); if (bounds.isEmpty()) { mMainHighlightDrawable.setBounds(0, 0, view.getWidth(), view.getHeight()); } else { mMainHighlightDrawable.setBounds(bounds); } int total = mHighlightDrawables.length; for (int i = 0; i < total; i++) { HighlightDrawable drawable = mHighlightDrawables[i]; drawable.highlightView(view); view.getOverlay().add(drawable); } }
@Implementation protected boolean getGlobalVisibleRect(Rect rect, Point globalOffset) { if (globalVisibleRect == null) { return directly().getGlobalVisibleRect(rect, globalOffset); } if (!globalVisibleRect.isEmpty()) { rect.set(globalVisibleRect); if (globalOffset != null) { rect.offset(-globalOffset.x, -globalOffset.y); } return true; } rect.setEmpty(); return false; }
Math.min(bottom, scrollingParentHeight) - top); if (rect.isEmpty()) {
private void setupPreviousMountableOutputData(LayoutState layoutState, Rect localVisibleRect) { if (localVisibleRect.isEmpty()) { return; } final ArrayList<LayoutOutput> layoutOutputTops = layoutState.getMountableOutputTops(); final ArrayList<LayoutOutput> layoutOutputBottoms = layoutState.getMountableOutputBottoms(); final int mountableOutputCount = layoutState.getMountableOutputCount(); mPreviousTopsIndex = layoutState.getMountableOutputCount(); for (int i = 0; i < mountableOutputCount; i++) { if (localVisibleRect.bottom <= layoutOutputTops.get(i).getBounds().top) { mPreviousTopsIndex = i; break; } } mPreviousBottomsIndex = layoutState.getMountableOutputCount(); for (int i = 0; i < mountableOutputCount; i++) { if (localVisibleRect.top < layoutOutputBottoms.get(i).getBounds().bottom) { mPreviousBottomsIndex = i; break; } } }
@Test public void setsGlobalVisibleRect() { Rect globalVisibleRect = new Rect(); shadowOf(view).setGlobalVisibleRect(new Rect()); assertThat(view.getGlobalVisibleRect(globalVisibleRect)) .isFalse(); assertThat(globalVisibleRect.isEmpty()) .isTrue(); assertThat(view.getGlobalVisibleRect(globalVisibleRect, new Point(1, 1))) .isFalse(); assertThat(globalVisibleRect.isEmpty()) .isTrue(); shadowOf(view).setGlobalVisibleRect(new Rect(1, 2, 3, 4)); assertThat(view.getGlobalVisibleRect(globalVisibleRect)) .isTrue(); assertThat(globalVisibleRect) .isEqualTo(new Rect(1, 2, 3, 4)); assertThat(view.getGlobalVisibleRect(globalVisibleRect, new Point(1, 1))) .isTrue(); assertThat(globalVisibleRect) .isEqualTo(new Rect(0, 1, 2, 3)); }