@Override public void setBounds(@NonNull Rect bounds) { if (!getBounds().equals(bounds)) checkedBitmap = uncheckedBitmap = filledBitmap = null; super.setBounds(bounds); }
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); } } }
@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); }
/** * 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); }
@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; } })
@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; } })
@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; } })
@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(); }
@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(); }
(startMatrix != null && startMatrix.equals(endMatrix)); if (startBounds.equals(endBounds) && matricesEqual) { return null;
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); } }
if (startBounds == null || endBounds == null || startBounds.equals(endBounds)) { return null;
set.playTogether(anim1); if (mResizeBehavior == RESIZE_BEHAVIOR_SCALE && !startBounds.equals(endBounds)) { if (Transition.DBG) { Log.d(LOG_TAG, "animating from startBounds to endBounds: " +
set.playTogether(anim1); if (mResizeBehavior == RESIZE_BEHAVIOR_SCALE && !startBounds.equals(endBounds)) { Animator anim2 = ObjectAnimator.ofObject(startDrawable, "bounds", sRectEvaluator, startBounds, endBounds);
return !tmpViewRect.equals(view);
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); } } } }
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,
&& ComponentsConfiguration.incrementalMountWhenNotVisible && currentVisibleArea != null && currentVisibleArea.equals(mLithoView.getPreviousMountBounds())) { return;
@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; }
@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(); } } }