本文整理了Java中android.graphics.Rect.isEmpty
方法的一些代码示例,展示了Rect.isEmpty
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rect.isEmpty
方法的具体详情如下:
包路径:android.graphics.Rect
类名称:Rect
方法名:isEmpty
[英]Returns true if the rectangle is empty (left >= right or top >= bottom)
[中]如果矩形为空(左>=右或上>=下),则返回true
代码示例来源:origin: bluelinelabs/Conductor
@Override
public Rect onGetEpicenter(Transition transition) {
if (toEpicenter.isEmpty()) {
return null;
}
return toEpicenter;
}
});
代码示例来源:origin: facebook/litho
@Nullable
Rect getExpandedTouchBounds() {
if (mExpandedTouchBounds == null || mExpandedTouchBounds.isEmpty()) {
return null;
}
return mExpandedTouchBounds;
}
代码示例来源:origin: facebook/litho
private static int computeRectArea(Rect rect) {
return rect.isEmpty() ? 0 : (rect.width() * rect.height());
}
代码示例来源:origin: rey5137/material
protected void drawSelectorCompat(Canvas canvas) {
if (!mSelectorRect.isEmpty()) {
final Drawable selector = getSelector();
if (selector != null) {
selector.setBounds(mSelectorRect);
selector.draw(canvas);
}
}
}
/**
代码示例来源:origin: chentao0707/SimplifyReader
private void drawSelector(Canvas canvas) {
if (shouldShowSelector() && mSelectorRect != null && !mSelectorRect.isEmpty()) {
final Drawable selector = mSelector;
selector.setBounds(mSelectorRect);
selector.draw(canvas);
}
}
代码示例来源:origin: sephiroth74/ImageViewZoom
@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);
}
}
}
代码示例来源:origin: lyft/scissors
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;
}
代码示例来源:origin: seven332/EhViewer
@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);
}
}
}
代码示例来源:origin: nickbutcher/plaid
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);
}
}
代码示例来源:origin: square/assertj-android
public RectAssert isNotEmpty() {
isNotNull();
assertThat(actual.isEmpty()) //
.overridingErrorMessage("Expected to not be empty but was.") //
.isFalse();
return this;
}
代码示例来源:origin: square/assertj-android
public RectAssert isEmpty() {
isNotNull();
assertThat(actual.isEmpty()) //
.overridingErrorMessage("Expected to be empty but was not.") //
.isTrue();
return this;
}
代码示例来源:origin: dinuscxj/LoadingDrawable
@Override
public void draw(Canvas canvas) {
if (!getBounds().isEmpty()) {
this.mLoadingRender.draw(canvas);
}
}
代码示例来源:origin: qiujuer/Genius-Android
@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;
}
代码示例来源:origin: LuckyJayce/LargeImage
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);
}
}
}
}
代码示例来源:origin: seven332/EhViewer
@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);
}
}
}
代码示例来源:origin: facebook/stetho
@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);
}
}
代码示例来源:origin: robolectric/robolectric
@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;
}
代码示例来源:origin: facebook/litho
Math.min(bottom, scrollingParentHeight) - top);
if (rect.isEmpty()) {
代码示例来源:origin: facebook/litho
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;
}
}
}
代码示例来源:origin: robolectric/robolectric
@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));
}
内容来源于网络,如有侵权,请联系作者删除!