当前位置: 首页>>代码示例>>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;未经允许,请勿转载。