@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.set(gridMargin, gridMargin, gridMargin, gridMargin); } });
@Implementation protected void getBoundsInScreen(Rect outBounds) { if (boundsInScreen == null) { outBounds.setEmpty(); } else { outBounds.set(boundsInScreen); } }
public void setGlobalVisibleRect(Rect rect) { if (rect != null) { globalVisibleRect = new Rect(); globalVisibleRect.set(rect); } else { globalVisibleRect = null; } }
/** * calculates the approximate height of a text, depending on a demo text * avoid repeated calls (e.g. inside drawing methods) * * @param paint * @param demoText * @return */ public static int calcTextHeight(Paint paint, String demoText) { Rect r = mCalcTextHeightRect; r.set(0,0,0,0); paint.getTextBounds(demoText, 0, demoText.length(), r); return r.height(); }
/** * calculates the approximate size of a text, depending on a demo text * avoid repeated calls (e.g. inside drawing methods) * * @param paint * @param demoText * @param outputFSize An output variable, modified by the function. */ public static void calcTextSize(Paint paint, String demoText, FSize outputFSize) { Rect r = mCalcTextSizeRect; r.set(0,0,0,0); paint.getTextBounds(demoText, 0, demoText.length(), r); outputFSize.width = r.width(); outputFSize.height = r.height(); }
@Nullable @Override public Object getElementToHighlightAtPosition(View element, int x, int y, Rect bounds) { bounds.set(0, 0, element.getWidth(), element.getHeight()); return element; }
private void update() { bufferedBar.set(progressBar); scrubberBar.set(progressBar); long newScrubberTime = scrubbing ? scrubPosition : position; if (duration > 0) { int bufferedPixelWidth = (int) ((progressBar.width() * bufferedPosition) / duration); bufferedBar.right = Math.min(progressBar.left + bufferedPixelWidth, progressBar.right); int scrubberPixelPosition = (int) ((progressBar.width() * newScrubberTime) / duration); scrubberBar.right = Math.min(progressBar.left + scrubberPixelPosition, progressBar.right); } else { bufferedBar.right = progressBar.left; scrubberBar.right = progressBar.left; } invalidate(seekBounds); }
@Implementation protected void getBoundsInScreen(Rect outBounds) { if (boundsInScreen == null) { boundsInScreen = new Rect(); } outBounds.set(boundsInScreen); }
@Implementation protected void setBoundsInScreen(Rect b) { if (boundsInScreen == null) { boundsInScreen = new Rect(b); } else { boundsInScreen.set(b); } }
@Implementation protected void setBoundsInParent(Rect b) { if (boundsInParent == null) { boundsInParent = new Rect(b); } else { boundsInParent.set(b); } }
static void ImageDecoder_nGetPadding(long nativePtr, Rect outPadding) { CppImageDecoder decoder = NATIVE_IMAGE_DECODER_REGISTRY.getNativeObject(nativePtr); // decoder.mPeeker.getPadding(outPadding); if (decoder.imgStream.isNinePatch()) { outPadding.set(0, 0, 0, 0); } else { outPadding.set(-1, -1, -1, -1); } }
@Implementation protected void getBoundsInParent(Rect outBounds) { if (boundsInParent == null) { boundsInParent = new Rect(); } outBounds.set(boundsInParent); }
@Override protected void onBoundsChange(Rect bounds) { mDstRect.set(bounds); if (mTransform != null) { mTransform.onBoundsChange(bounds); } }
@Override public void drawLayer(@NonNull Canvas canvas, Matrix parentMatrix, int parentAlpha) { Bitmap bitmap = getBitmap(); if (bitmap == null || bitmap.isRecycled()) { return; } float density = Utils.dpScale(); paint.setAlpha(parentAlpha); if (colorFilterAnimation != null) { paint.setColorFilter(colorFilterAnimation.getValue()); } canvas.save(); canvas.concat(parentMatrix); src.set(0, 0, bitmap.getWidth(), bitmap.getHeight()); dst.set(0, 0, (int) (bitmap.getWidth() * density), (int) (bitmap.getHeight() * density)); canvas.drawBitmap(bitmap, src, dst , paint); canvas.restore(); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { int width = right - left; int height = bottom - top; int barY = (height - touchTargetHeight) / 2; int seekLeft = getPaddingLeft(); int seekRight = width - getPaddingRight(); int progressY = barY + (touchTargetHeight - barHeight) / 2; seekBounds.set(seekLeft, barY, seekRight, barY + touchTargetHeight); progressBar.set(seekBounds.left + scrubberPadding, progressY, seekBounds.right - scrubberPadding, progressY + barHeight); update(); }
public void setExpandedBounds(int left, int top, int right, int bottom) { if (!rectEquals(mExpandedBounds, left, top, right, bottom)) { mExpandedBounds.set(left, top, right, bottom); mBoundsChanged = true; onBoundsChanged(); } }
public void setCollapsedBounds(int left, int top, int right, int bottom) { if (!rectEquals(mCollapsedBounds, left, top, right, bottom)) { mCollapsedBounds.set(left, top, right, bottom); mBoundsChanged = true; onBoundsChanged(); } }
public void setOffset(int offset) { offset = Math.max(minOffset, offset); if (offset != getTranslationY()) { setTranslationY(offset); imageOffset = (int) (offset * parallaxFactor); clipBounds.set(0, -offset, getWidth(), getHeight()); setClipBounds(clipBounds); setScrimAlpha(Math.min( ((float) -offset / getMinimumHeight()) * maxScrimAlpha, maxScrimAlpha)); postInvalidateOnAnimation(); } setPinned(offset == minOffset); }
@Test public void setWithRectSetsCoordinates() { Rect rSrc = new Rect(1, 2, 3, 4); Rect r = new Rect(); r.set(rSrc); assertThat(r.left).isEqualTo(1); assertThat(r.top).isEqualTo(2); assertThat(r.right).isEqualTo(3); assertThat(r.bottom).isEqualTo(4); }
@Test public void setWithIntsSetsCoordinates() { Rect r = new Rect(); r.set(1, 2, 3, 4); assertThat(r.left).isEqualTo(1); assertThat(r.top).isEqualTo(2); assertThat(r.right).isEqualTo(3); assertThat(r.bottom).isEqualTo(4); }