android.graphics.Rect.equals()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中android.graphics.Rect.equals方法的一些代码示例,展示了Rect.equals的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rect.equals方法的具体详情如下:
包路径:android.graphics.Rect
类名称:Rect
方法名:equals

Rect.equals介绍

暂无

代码示例

代码示例来源:origin: ZieIony/Carbon

@Override
public void setBounds(@NonNull Rect bounds) {
  if (!getBounds().equals(bounds))
    checkedBitmap = uncheckedBitmap = filledBitmap = null;
  super.setBounds(bounds);
}

代码示例来源:origin: facebook/stetho

private void highlightViewOnUiThread() {
  final View viewToHighlight = mViewToHighlight.getAndSet(null);
  Rect boundsToHighlight = mBoundsToHighlight.getAndSet(null);
  if (boundsToHighlight == null) {
   boundsToHighlight = mEmptyRect;
  }
  if (viewToHighlight == mHighlightedView && mHighlightedBounds.equals(boundsToHighlight)) {
   return;
  }
  if (mHighlightedView != null) {
   mHighlightOverlays.removeHighlight(mHighlightedView);
  }
  if (viewToHighlight != null) {
   mHighlightOverlays.highlightView(
     viewToHighlight,
     boundsToHighlight,
     mContentColor.get());
  }
  mHighlightedView = viewToHighlight;
  if (boundsToHighlight == null) {
   mHighlightedBounds.setEmpty();
  } else {
   mHighlightedBounds.set(boundsToHighlight);
  }
 }
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Nullable
@Override
public Animator createAnimator(@NonNull final ViewGroup sceneRoot, @Nullable TransitionValues startValues,
                @Nullable TransitionValues endValues) {
  if (startValues == null || endValues == null
      || !startValues.values.containsKey(PROPNAME_CLIP)
      || !endValues.values.containsKey(PROPNAME_CLIP)) {
    return null;
  }
  Rect start = (Rect) startValues.values.get(PROPNAME_CLIP);
  Rect end = (Rect) endValues.values.get(PROPNAME_CLIP);
  if (start == null && end == null) {
    return null; // No animation required since there is no clip.
  }
  if (start == null) {
    start = (Rect) startValues.values.get(PROPNAME_BOUNDS);
  } else if (end == null) {
    end = (Rect) endValues.values.get(PROPNAME_BOUNDS);
  }
  if (start.equals(end)) {
    return null;
  }
  ViewUtils.setClipBounds(endValues.view, start);
  RectEvaluator evaluator = new RectEvaluator(new Rect());
  return ObjectAnimator.ofObject(endValues.view, VIEW_CLIP_BOUNDS, evaluator, start, end);
}

代码示例来源:origin: facebook/litho

/**
 * Returns true if the component is in the focused visible range.
 */
private boolean isInFocusedRange(
  Rect componentBounds,
  Rect componentVisibleBounds) {
 final View parent = (View) mLithoView.getParent();
 if (parent == null) {
  return false;
 }
 final int halfViewportArea = parent.getWidth() * parent.getHeight() / 2;
 final int totalComponentArea = computeRectArea(componentBounds);
 final int visibleComponentArea = computeRectArea(componentVisibleBounds);
 // The component has entered the focused range either if it is larger than half of the viewport
 // and it occupies at least half of the viewport or if it is smaller than half of the viewport
 // and it is fully visible.
 return (totalComponentArea >= halfViewportArea)
   ? (visibleComponentArea >= halfViewportArea)
   : componentBounds.equals(componentVisibleBounds);
}

代码示例来源:origin: facebook/litho

@Override
 public Object answer(InvocationOnMock invocation) throws Throwable {
  Rect rect = (Rect) invocation.getArguments()[0];
  if (!rect.equals(new Rect(0, 0, 15, 20))) {
   fail();
  }
  return null;
 }
})

代码示例来源:origin: facebook/litho

@Override
 public Object answer(InvocationOnMock invocation) throws Throwable {
  Rect rect = (Rect) invocation.getArguments()[0];
  if (!rect.equals(new Rect(0, 0, 40, 50))) {
   fail();
  }
  return null;
 }
})

代码示例来源:origin: facebook/litho

@Override
 public Object answer(InvocationOnMock invocation) throws Throwable {
  Rect rect = (Rect) invocation.getArguments()[0];
  if (!rect.equals(new Rect(0, 0, 20, 25))) {
   fail();
  }
  return null;
 }
})

代码示例来源:origin: robolectric/robolectric

@Test
public void doesntEqual() {
 Rect a = new Rect(1, 2, 3, 4);
 Rect b = new Rect(2, 3, 4, 5);
 assertThat(a.equals(b)).isFalse();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void equals() {
 Rect a = new Rect(1, 2, 3, 4);
 Rect b = new Rect(1, 2, 3, 4);
 assertThat(a.equals(b)).isTrue();
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

(startMatrix != null && startMatrix.equals(endMatrix));
if (startBounds.equals(endBounds) && matricesEqual) {
  return null;

代码示例来源:origin: ZieIony/Carbon

private void drawView(Canvas canvas, View v) {
  int[] l = new int[2];
  v.getLocationOnScreen(l);
  rect.set(0, 0, v.getWidth(), v.getHeight());
  rect.offset(l[0] - location[0], l[1] - location[1]);
  if (drawMargins)
    drawMargins(canvas, v);
  if (drawPaddings)
    drawPaddings(canvas, v);
  if (drawBounds)
    drawBounds(canvas, v);
  if (drawHitRects) {
    v.getHitRect(rect2);
    rect2.offset(l[0] - location[0] - v.getLeft(), l[1] - location[1] - v.getTop());
    if (!rect.equals(rect2)) {
      paint.setColor(0x7fff0000);
      canvas.drawRect(rect2, paint);
    }
  }
  if (drawTextSizes && v instanceof TextView) {
    TextView tv = (TextView) v;
    paint.setTextSize(12);
    float textSize = tv.getTextSize() / getResources().getDisplayMetrics().scaledDensity;
    paint.setColor(Color.WHITE);
    paint.setShadowLayer(2, 0, 0, 0xff000000);
    canvas.drawText(textSize + "sp", rect.left, rect.top + paint.getTextSize(), paint);
  }
}

代码示例来源:origin: naman14/Timber

if (startBounds == null || endBounds == null || startBounds.equals(endBounds)) {
  return null;

代码示例来源:origin: andkulikov/Transitions-Everywhere

set.playTogether(anim1);
if (mResizeBehavior == RESIZE_BEHAVIOR_SCALE && !startBounds.equals(endBounds)) {
  if (Transition.DBG) {
    Log.d(LOG_TAG, "animating from startBounds to endBounds: " +

代码示例来源:origin: andkulikov/Transitions-Everywhere

set.playTogether(anim1);
if (mResizeBehavior == RESIZE_BEHAVIOR_SCALE && !startBounds.equals(endBounds)) {
  Animator anim2 = ObjectAnimator.ofObject(startDrawable, "bounds",
      sRectEvaluator, startBounds, endBounds);

代码示例来源:origin: alexvasilkov/GestureViews

return !tmpViewRect.equals(view);

代码示例来源: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: andkulikov/Transitions-Everywhere

if (startRight != endRight || startBottom != endBottom) ++numChanges;
if ((startClip != null && !startClip.equals(endClip)) ||
    (startClip == null && endClip != null)) {
  ++numChanges;
    if (!startClip.equals(endClip)) {
      ViewUtils.setClipBounds(view, startClip);
      clipAnimator = ObjectAnimator.ofObject(view,

代码示例来源:origin: facebook/litho

&& ComponentsConfiguration.incrementalMountWhenNotVisible
 && currentVisibleArea != null
 && currentVisibleArea.equals(mLithoView.getPreviousMountBounds())) {
return;

代码示例来源:origin: robolectric/robolectric

@Override
@Implementation
@SuppressWarnings("ReferenceEquality")
public boolean equals(Object object) {
 if (!(object instanceof AccessibilityWindowInfo)) {
  return false;
 }
 final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object;
 final ShadowAccessibilityWindowInfo otherShadow = Shadow.extract(window);
 boolean areEqual = (type == otherShadow.getType());
 areEqual &= (parent == otherShadow.getParent());
 areEqual &= (rootNode == otherShadow.getRoot());
 areEqual &= (layer == otherShadow.getLayer());
 areEqual &= (id == otherShadow.getId());
 areEqual &= (title == otherShadow.getTitle());
 areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused());
 areEqual &= (isActive == otherShadow.isActive());
 areEqual &= (isFocused == otherShadow.isFocused());
 Rect anotherBounds = new Rect();
 otherShadow.getBoundsInScreen(anotherBounds);
 areEqual &= (boundsInScreen.equals(anotherBounds));
 return areEqual;
}

代码示例来源:origin: google/santa-tracker-android

@SuppressWarnings("deprecation") // Wear 1.0 compatibility
  @Override
  public void onPeekCardPositionUpdate(Rect bounds) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
      Log.d(TAG, "onPeekCardPositionUpdate: " + bounds);
    }
    super.onPeekCardPositionUpdate(bounds);
    if (!bounds.equals(mCardBounds)) {
      mCardBounds.set(bounds);
      invalidate();
    }
  }
}

相关文章