當前位置: 首頁>>代碼示例>>Java>>正文


Java Rect.setEmpty方法代碼示例

本文整理匯總了Java中android.graphics.Rect.setEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java Rect.setEmpty方法的具體用法?Java Rect.setEmpty怎麽用?Java Rect.setEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Rect的用法示例。


在下文中一共展示了Rect.setEmpty方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calculateClippingRect

import android.graphics.Rect; //導入方法依賴的package包/類
/**
 * Can be used by view that support {@code removeClippedSubviews} property to calculate area that
 * given {@param view} should be clipped to based on the clipping rectangle of it's parent in
 * case when parent is also set to clip it's children.
 *
 * @param view view that we want to calculate clipping rect for
 * @param outputRect where the calculated rectangle will be written
 */
public static void calculateClippingRect(View view, Rect outputRect) {
  ViewParent parent = view.getParent();
  if (parent == null) {
    outputRect.setEmpty();
    return;
  } else if (parent instanceof ReactClippingViewGroup) {
    ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent;
    if (clippingViewGroup.getRemoveClippedSubviews()) {
      clippingViewGroup.getClippingRect(sHelperRect);
      // Intersect the view with the parent's rectangle
      // This will result in the overlap with coordinates in the parent space
      if (!sHelperRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
        outputRect.setEmpty();
        return;
      }
      // Now we move the coordinates to the View's coordinate space
      sHelperRect.offset(-view.getLeft(), -view.getTop());
      sHelperRect.offset(view.getScrollX(), view.getScrollY());
      outputRect.set(sHelperRect);
      return;
    }
  }
  view.getDrawingRect(outputRect);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:33,代碼來源:ReactClippingViewGroupHelper.java

示例2: getItemOffsets

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (parent.getChildAdapterPosition(view) < mColumns) {
        if (mHorizontal) {
            if (mView.getMeasuredWidth() <= 0) {
                mView.measure(View.MeasureSpec.makeMeasureSpec(parent.getMeasuredWidth(), View.MeasureSpec.AT_MOST),
                        View.MeasureSpec.makeMeasureSpec(parent.getMeasuredHeight(), View.MeasureSpec.AT_MOST));
            }
            outRect.set(mView.getMeasuredWidth(), 0, 0, 0);
        } else {
            if (mView.getMeasuredHeight() <= 0) {
                mView.measure(View.MeasureSpec.makeMeasureSpec(parent.getMeasuredWidth(), View.MeasureSpec.AT_MOST),
                        View.MeasureSpec.makeMeasureSpec(parent.getMeasuredHeight(), View.MeasureSpec.AT_MOST));
            }
            outRect.set(0, mView.getMeasuredHeight(), 0, 0);
        }
    } else {
        outRect.setEmpty();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:HeaderShadowDecoration.java

示例3: onItemClicked

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void onItemClicked(MotionEvent event, View v, Object dataObject) {
    if (v.getTag() instanceof ViewHolder) {
        int x = (int) event.getRawX();
        int y = (int) event.getRawY();
        ViewHolder vh = (ViewHolder) v.getTag();
        View child = vh.portraitView;
        Rect outRect = new Rect();
        child.getGlobalVisibleRect(outRect);
        if (outRect.contains(x, y)) {
            AppToast.show(this, "click 大圖");
        } else {
            outRect.setEmpty();
            child = vh.collectView;
            child.getGlobalVisibleRect(outRect);
            if (outRect.contains(x, y)) {
                AppToast.show(this, "click 關注");
            }
        }
    }
}
 
開發者ID:marven88cn,項目名稱:SwipeCard-,代碼行數:22,代碼來源:MainActivity.java

示例4: getChildRect

import android.graphics.Rect; //導入方法依賴的package包/類
/**
   * Get the position rect for the given child. If the child has currently requested layout
   * or has a visibility of GONE.
 *
 * @param child child view to check
   * @param transform true to include transformation in the output rect, false to
   *                        only account for the base position
 * @param out rect to set to the output values
 */
void getChildRect(View child, boolean transform, Rect out) {
  if (child.isLayoutRequested() || child.getVisibility() == View.GONE) {
    out.setEmpty();
    return;
  }
  if (transform) {
    getDescendantRect(child, out);
  } else {
    out.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
  }
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:21,代碼來源:CoordinatorLayout.java

示例5: adjustLayout

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
    if (requireLayoutView()) {
        View refer = null;
        Rect tempRect = new Rect();
        final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
        for (int i = 0; i < helper.getChildCount(); i++) {
            refer = helper.getChildAt(i);
            int anchorPos = helper.getPosition(refer);
            if (getRange().contains(anchorPos)) {
                if (refer.getVisibility() == View.GONE) {
                    tempRect.setEmpty();
                } else {
                    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
                        refer.getLayoutParams();
                    if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
                        tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
                            orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedRight(refer) + params.rightMargin,
                            orientationHelper.getDecoratedEnd(refer));
                    } else {
                        tempRect.union(orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
                            helper.getDecoratedBottom(refer) + params.bottomMargin);
                    }
                }
            }
        }
        if (!tempRect.isEmpty()) {
            mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
                tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
        } else {
            mLayoutRegion.setEmpty();
        }
        if (mLayoutView != null) {
            mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:40,代碼來源:BaseLayoutHelper.java

示例6: adjustLayout

import android.graphics.Rect; //導入方法依賴的package包/類
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
    if (!isChildrenEmpty()) {
        for (int i = 0, size = mChildren.size(); i < size; i++) {
            RangeStyle rangeStyle = mChildren.valueAt(i);
            rangeStyle.adjustLayout(startPosition, endPosition, helper);
        }
    }
    if (requireLayoutView()) {
        View refer = null;
        Rect tempRect = new Rect();
        final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
        for (int i = 0; i < helper.getChildCount(); i++) {
            refer = helper.getChildAt(i);
            int anchorPos = helper.getPosition(refer);
            if (getRange().contains(anchorPos)) {
                if (refer.getVisibility() == View.GONE) {
                    tempRect.setEmpty();
                } else {
                    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
                        refer.getLayoutParams();
                    if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
                        tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
                            orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedRight(refer) + params.rightMargin,
                            orientationHelper.getDecoratedEnd(refer));
                    } else {
                        tempRect.union(orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
                            helper.getDecoratedBottom(refer) + params.bottomMargin);
                    }
                }
            }
        }
        if (!tempRect.isEmpty()) {
            mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
                tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
        } else {
            mLayoutRegion.setEmpty();
        }
        if (mLayoutView != null) {
            mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:45,代碼來源:RangeStyle.java

示例7: getItemOffsets

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
        RecyclerView.State state) {
    outRect.setEmpty();
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:6,代碼來源:ItemTouchHelper.java

示例8: onMeasure

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final Rect padding = mTempRect;
    int thumbWidth;
    int thumbHeight;
    if (mThumbDrawable != null) {
        mThumbDrawable.getPadding(padding);
        thumbWidth = mThumbDrawable.getIntrinsicWidth() - padding.left - padding.right;
        thumbHeight = mThumbDrawable.getIntrinsicHeight();
    } else {
        thumbWidth = 0;
        thumbHeight = 0;
    }


    mThumbWidth = thumbWidth;

    int trackHeight;
    if (mTrackDrawable != null) {
        mTrackDrawable.getPadding(padding);
        trackHeight = mTrackDrawable.getIntrinsicHeight();
    } else {
        padding.setEmpty();
        trackHeight = 0;
    }

    int paddingLeft = padding.left;
    int paddingRight = padding.right;
    if (mThumbDrawable != null) {
        final Insets inset = Insets.NONE;
        paddingLeft = Math.max(paddingLeft, inset.left);
        paddingRight = Math.max(paddingRight, inset.right);
    }

    final int switchWidth = Math.max(mSwitchMinWidth, 2 * mThumbWidth + paddingLeft + paddingRight);
    final int switchHeight = Math.max(trackHeight, thumbHeight);
    mSwitchWidth = switchWidth;
    mSwitchHeight = switchHeight;

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    final int measuredHeight = getMeasuredHeight();
    if (measuredHeight < switchHeight) {
        setMeasuredDimension(switchWidth, switchHeight);
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:47,代碼來源:Switch.java

示例9: onLayout

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    wasLayout = true;
    int opticalInsetLeft = 0;
    int opticalInsetRight = 0;
    if (mThumbDrawable != null) {
        final Rect trackPadding = mTempRect;
        if (mTrackDrawable != null) {
            mTrackDrawable.getPadding(trackPadding);
        } else {
            trackPadding.setEmpty();
        }

        final Insets insets = Insets.NONE;
        opticalInsetLeft = Math.max(0, insets.left - trackPadding.left);
        opticalInsetRight = Math.max(0, insets.right - trackPadding.right);
    }

    final int switchRight;
    final int switchLeft;
    if (LocaleController.isRTL) {
        switchLeft = getPaddingLeft() + opticalInsetLeft;
        switchRight = switchLeft + mSwitchWidth - opticalInsetLeft - opticalInsetRight;
    } else {
        switchRight = getWidth() - getPaddingRight() - opticalInsetRight;
        switchLeft = switchRight - mSwitchWidth + opticalInsetLeft + opticalInsetRight;
    }

    final int switchTop;
    final int switchBottom;
    switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK) {
        default:
        case Gravity.TOP:
            switchTop = getPaddingTop();
            switchBottom = switchTop + mSwitchHeight;
            break;

        case Gravity.CENTER_VERTICAL:
            switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 - mSwitchHeight / 2;
            switchBottom = switchTop + mSwitchHeight;
            break;

        case Gravity.BOTTOM:
            switchBottom = getHeight() - getPaddingBottom();
            switchTop = switchBottom - mSwitchHeight;
            break;
    }

    mSwitchLeft = switchLeft;
    mSwitchTop = switchTop;
    mSwitchBottom = switchBottom;
    mSwitchRight = switchRight;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:56,代碼來源:Switch.java

示例10: getItemOffsets

import android.graphics.Rect; //導入方法依賴的package包/類
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) {
    outRect.setEmpty();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:ItemTouchHelper.java

示例11: releaseTempRect

import android.graphics.Rect; //導入方法依賴的package包/類
private static void releaseTempRect(@NonNull Rect rect) {
  rect.setEmpty();
  sRectPool.release(rect);
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:5,代碼來源:CoordinatorLayout.java

示例12: onMeasure

import android.graphics.Rect; //導入方法依賴的package包/類
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int thumbWidth;
    int thumbHeight;
    int maxTextWidth;
    int trackHeight;
    if (this.mShowText) {
        if (this.mOnLayout == null) {
            this.mOnLayout = makeLayout(this.mTextOn);
        }
        if (this.mOffLayout == null) {
            this.mOffLayout = makeLayout(this.mTextOff);
        }
    }
    Rect padding = this.mTempRect;
    if (this.mThumbDrawable != null) {
        this.mThumbDrawable.getPadding(padding);
        thumbWidth = (this.mThumbDrawable.getIntrinsicWidth() - padding.left) - padding.right;
        thumbHeight = this.mThumbDrawable.getIntrinsicHeight();
    } else {
        thumbWidth = 0;
        thumbHeight = 0;
    }
    if (this.mShowText) {
        maxTextWidth = Math.max(this.mOnLayout.getWidth(), this.mOffLayout.getWidth()) + (this.mThumbTextPadding * 2);
    } else {
        maxTextWidth = 0;
    }
    this.mThumbWidth = Math.max(maxTextWidth, thumbWidth);
    if (this.mTrackDrawable != null) {
        this.mTrackDrawable.getPadding(padding);
        trackHeight = this.mTrackDrawable.getIntrinsicHeight();
    } else {
        padding.setEmpty();
        trackHeight = 0;
    }
    int paddingLeft = padding.left;
    int paddingRight = padding.right;
    if (this.mThumbDrawable != null) {
        Rect inset = DrawableUtils.getOpticalBounds(this.mThumbDrawable);
        paddingLeft = Math.max(paddingLeft, inset.left);
        paddingRight = Math.max(paddingRight, inset.right);
    }
    int switchWidth = Math.max(this.mSwitchMinWidth, ((this.mThumbWidth * 2) + paddingLeft) + paddingRight);
    int switchHeight = Math.max(trackHeight, thumbHeight);
    this.mSwitchWidth = switchWidth;
    this.mSwitchHeight = switchHeight;
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (getMeasuredHeight() < switchHeight) {
        setMeasuredDimension(ViewCompat.getMeasuredWidthAndState(this), switchHeight);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:52,代碼來源:SwitchCompat.java

示例13: onLayout

import android.graphics.Rect; //導入方法依賴的package包/類
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int switchLeft;
    int switchRight;
    int switchTop;
    int switchBottom;
    super.onLayout(changed, left, top, right, bottom);
    int opticalInsetLeft = 0;
    int opticalInsetRight = 0;
    if (this.mThumbDrawable != null) {
        Rect trackPadding = this.mTempRect;
        if (this.mTrackDrawable != null) {
            this.mTrackDrawable.getPadding(trackPadding);
        } else {
            trackPadding.setEmpty();
        }
        Rect insets = DrawableUtils.getOpticalBounds(this.mThumbDrawable);
        opticalInsetLeft = Math.max(0, insets.left - trackPadding.left);
        opticalInsetRight = Math.max(0, insets.right - trackPadding.right);
    }
    if (ViewUtils.isLayoutRtl(this)) {
        switchLeft = getPaddingLeft() + opticalInsetLeft;
        switchRight = ((this.mSwitchWidth + switchLeft) - opticalInsetLeft) - opticalInsetRight;
    } else {
        switchRight = (getWidth() - getPaddingRight()) - opticalInsetRight;
        switchLeft = ((switchRight - this.mSwitchWidth) + opticalInsetLeft) + opticalInsetRight;
    }
    switch (getGravity() & 112) {
        case 16:
            switchTop = (((getPaddingTop() + getHeight()) - getPaddingBottom()) / 2) - (this.mSwitchHeight / 2);
            switchBottom = switchTop + this.mSwitchHeight;
            break;
        case 80:
            switchBottom = getHeight() - getPaddingBottom();
            switchTop = switchBottom - this.mSwitchHeight;
            break;
        default:
            switchTop = getPaddingTop();
            switchBottom = switchTop + this.mSwitchHeight;
            break;
    }
    this.mSwitchLeft = switchLeft;
    this.mSwitchTop = switchTop;
    this.mSwitchBottom = switchBottom;
    this.mSwitchRight = switchRight;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:46,代碼來源:SwitchCompat.java

示例14: onDraw

import android.graphics.Rect; //導入方法依賴的package包/類
protected void onDraw(Canvas canvas) {
    int saveCount;
    Layout switchText;
    super.onDraw(canvas);
    Rect padding = this.mTempRect;
    Drawable trackDrawable = this.mTrackDrawable;
    if (trackDrawable != null) {
        trackDrawable.getPadding(padding);
    } else {
        padding.setEmpty();
    }
    int switchTop = this.mSwitchTop;
    int switchInnerTop = switchTop + padding.top;
    int switchInnerBottom = this.mSwitchBottom - padding.bottom;
    Drawable thumbDrawable = this.mThumbDrawable;
    if (trackDrawable != null) {
        if (!this.mSplitTrack || thumbDrawable == null) {
            trackDrawable.draw(canvas);
        } else {
            Rect insets = DrawableUtils.getOpticalBounds(thumbDrawable);
            thumbDrawable.copyBounds(padding);
            padding.left += insets.left;
            padding.right -= insets.right;
            saveCount = canvas.save();
            canvas.clipRect(padding, Op.DIFFERENCE);
            trackDrawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
    }
    saveCount = canvas.save();
    if (thumbDrawable != null) {
        thumbDrawable.draw(canvas);
    }
    if (getTargetCheckedState()) {
        switchText = this.mOnLayout;
    } else {
        switchText = this.mOffLayout;
    }
    if (switchText != null) {
        int cX;
        int[] drawableState = getDrawableState();
        if (this.mTextColors != null) {
            this.mTextPaint.setColor(this.mTextColors.getColorForState(drawableState, 0));
        }
        this.mTextPaint.drawableState = drawableState;
        if (thumbDrawable != null) {
            Rect bounds = thumbDrawable.getBounds();
            cX = bounds.left + bounds.right;
        } else {
            cX = getWidth();
        }
        canvas.translate((float) ((cX / 2) - (switchText.getWidth() / 2)), (float) (((switchInnerTop + switchInnerBottom) / 2) - (switchText.getHeight() / 2)));
        switchText.draw(canvas);
    }
    canvas.restoreToCount(saveCount);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:57,代碼來源:SwitchCompat.java


注:本文中的android.graphics.Rect.setEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。