Java 类android.graphics.Rect 实例源码

项目:ceji_android    文件:CenteredImageSpan.java   
@Override
public int getSize(Paint paint, CharSequence text,
                   int start, int end,
                   Paint.FontMetricsInt fm) {
    Drawable d = getCachedDrawable();
    Rect rect = d.getBounds();

    if (fm != null) {
        // Centers the text with the ImageSpan
        if ((rect.bottom - (fm.descent - fm.ascent)) >= 0) {
            // Stores the initial descent and computes the margin available
            initialDescent = fm.descent;
            extraSpace = rect.bottom - (fm.descent - fm.ascent);
        }

        fm.descent = extraSpace / 2 + initialDescent;
        fm.bottom = fm.descent;

        fm.ascent = -rect.bottom + fm.descent;
        fm.top = fm.ascent;
    }

    return rect.right;
}
项目:tenor-android-demo-search    文件:SearchSuggestionRecyclerView.java   
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

    if (!AbstractWeakReferenceUtils.isAlive(mWeakRef)) {
        return;
    }

    outRect.left = mSpaceBetweenItems / 2;
    outRect.top = 0;
    outRect.right = mSpaceBetweenItems / 2;
    outRect.bottom = 0;

    final int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewAdapterPosition();
    final int total = parent.getAdapter().getItemCount();
    if (position == 0) {
        outRect.left = mSpaceOnBothEnds;
    } else if (position == total - 1) {
        outRect.right = mSpaceOnBothEnds;
    }
}
项目:weex-3d-map    文件:ScreenShot.java   
public static  int getStatusBarHeight(Activity activity) {
    int result = 0;
    Rect rect = new Rect();
    Window window = activity.getWindow();
    if (window != null) {
        window.getDecorView().getWindowVisibleDisplayFrame(rect);
        View v = window.findViewById(Window.ID_ANDROID_CONTENT);

        android.view.Display display = ((android.view.WindowManager) activity.getSystemService(activity.WINDOW_SERVICE)).getDefaultDisplay();

        //return result title bar height
        int result1 = display.getHeight() - v.getBottom() + rect.top;
        int result2  = display.getHeight() - v.getBottom();
        int result3 = v.getTop() - rect.top;
        int result4 = display.getHeight() - v.getHeight();

        Log.e("StatusBarHeight==", "result1== " + result1 +" result2 = " + result2 + "result3=" + result3 + "result4=" +result4  ) ;
    }
    return result;

}
项目:javaide    文件:ProjectManagerActivity.java   
public void onGlobalLayout() {
    int i = 0;
    int navHeight = this.activity.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
    navHeight = navHeight > 0 ? this.activity.getResources().getDimensionPixelSize(navHeight) : 0;
    int statusBarHeight = this.activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (statusBarHeight > 0) {
        i = this.activity.getResources().getDimensionPixelSize(statusBarHeight);
    }
    Rect rect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    if (activity.mDrawerLayout.getRootView().getHeight() - ((navHeight + i) + rect.height()) <= 0) {
        activity.onHideKeyboard();
    } else {
        activity.onShowKeyboard();
    }
}
项目:CSipSimple    文件:SearchView.java   
private void adjustDropDownSizeAndPosition() {
    if (mDropDownAnchor.getWidth() > 1) {
        Resources res = getContext().getResources();
        int anchorPadding = mSearchPlate.getPaddingLeft();
        Rect dropDownPadding = new Rect();
        int iconOffset = mIconifiedByDefault
                ? res.getDimensionPixelSize(R.dimen.abs__dropdownitem_icon_width)
                + res.getDimensionPixelSize(R.dimen.abs__dropdownitem_text_padding_left)
                : 0;
        mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
        mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
                + anchorPadding);
        mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
                + dropDownPadding.right + iconOffset - (anchorPadding));
    }
}
项目:GitHub    文件:ForwardingDrawableTest.java   
@Test
public void testCopyProperties() {
  Rect rect = new Rect(10, 20, 30, 40);
  int config = 11;
  int level = 100;
  boolean visible = true;
  int[] stateSet = new int[]{1, 2};

  mDrawable.setBounds(rect);
  mDrawable.setChangingConfigurations(config);
  mDrawable.setLevel(level);
  mDrawable.setVisible(visible, false);
  mDrawable.setState(stateSet);

  Drawable newDrawable = mock(Drawable.class);
  mDrawable.setCurrent(newDrawable);

  verify(newDrawable).setBounds(rect);
  verify(newDrawable).setChangingConfigurations(config);
  verify(newDrawable).setLevel(level);
  verify(newDrawable).setVisible(visible, false);
  verify(newDrawable).setState(stateSet);
}
项目:MyAnimeViewer    文件:HighlightView.java   
public void setup(Matrix m, Rect imageRect, RectF cropRect, boolean circle,
                  boolean maintainAspectRatio) {

    if (circle) {
        maintainAspectRatio = true;
    }
    mMatrix = new Matrix(m);

    mCropRect = cropRect;
    mImageRect = new RectF(imageRect);
    mMaintainAspectRatio = maintainAspectRatio;
    mCircle = circle;

    mInitialAspectRatio = mCropRect.width() / mCropRect.height();
    mDrawRect = computeLayout();

    mFocusPaint.setARGB(125, 50, 50, 50);
    mNoFocusPaint.setARGB(125, 50, 50, 50);
    mOutlinePaint.setStrokeWidth(3F);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);

    mMode = ModifyMode.None;
    init();
}
项目:UnversityFinance    文件:ClearEditText.java   
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(focused, direction, previouslyFocusedRect);
    isFocused = focused;
    if (focused && getText().length() > 0) {
        if (!isVisible) {
            isVisible = true;
            startVisibleAnimator();
        }
    } else {
        if (isVisible) {
            isVisible = false;
            startGoneAnimator();
        }
    }
}
项目:JueDiQiuSheng    文件:CoolWaitLoadingRenderer.java   
@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    RectF arcBounds = mCurrentBounds;
    arcBounds.set(bounds);

    mPaint.setColor(mBottomColor);
    canvas.drawPath(mCurrentBottomWaitPath, mPaint);

    mPaint.setColor(mMiddleColor);
    canvas.drawPath(mCurrentMiddleWaitPath, mPaint);

    mPaint.setColor(mTopColor);
    canvas.drawPath(mCurrentTopWaitPath, mPaint);

    canvas.restoreToCount(saveCount);
}
项目:boohee_v5.6    文件:SocialResHelper.java   
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
    Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config
            .ARGB_8888);
    Canvas canvas = new Canvas(createBitmap);
    Paint paint = new Paint();
    Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    RectF rectF = new RectF(rect);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(-12434878);
    if (RESUTIL_V2_DUBUG) {
        canvas.drawRoundRect(rectF, (float) (bitmap.getWidth() / 2), (float) (bitmap
                .getHeight() / 2), paint);
    } else {
        canvas.drawRoundRect(rectF, (float) (bitmap.getWidth() / 6), (float) (bitmap
                .getHeight() / 6), paint);
    }
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    bitmap.recycle();
    return createBitmap;
}
项目:GitHub    文件:WheelView.java   
private void measuredOutContentStart(String content) {
    Rect rect = new Rect();
    paintOuterText.getTextBounds(content, 0, content.length(), rect);
    switch (mGravity) {
        case Gravity.CENTER:
            if (isOptions||label == null|| label.equals("")||!isCenterLabel) {
                drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.5);
            } else {//只显示中间label时,时间选择器内容偏左一点,留出空间绘制单位标签
                drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.25);
            }
            break;
        case Gravity.LEFT:
            drawOutContentStart = 0;
            break;
        case Gravity.RIGHT:
            drawOutContentStart = measuredWidth - rect.width()-(int)centerContentOffset;
            break;
    }
}
项目:OpenYOLO-Android    文件:ProviderPickerActivity.java   
@Override
public boolean dispatchTouchEvent(MotionEvent event) {

    // finishWithUserCanceled() if the user tapped outside the picker
    if (MotionEvent.ACTION_DOWN == event.getAction()) {
        Rect visibilityRect = new Rect();
        mPickerContainer.getGlobalVisibleRect(visibilityRect);
        boolean tappedOutsidePicker =
                !visibilityRect.contains((int) event.getRawX(), (int) event.getRawY());
        if (tappedOutsidePicker) {
            finishWithUserCanceled();
        }
    }

    return super.dispatchTouchEvent(event);
}
项目:letv    文件:ViewfinderView.java   
private void drawScanningLine(Canvas canvas, Rect frame) {
    if (this.isFirst) {
        this.isFirst = false;
        this.slideTop = 0;
        this.slideBottom = frame.bottom - frame.top;
    }
    this.slideTop += 6;
    if (this.slideTop >= this.slideBottom - MIDDLE_LINE_WIDTH) {
        this.slideTop = 0;
    }
    Rect lineRect = new Rect();
    lineRect.left = frame.left + MIDDLE_LINE_PADDING;
    lineRect.right = frame.right - MIDDLE_LINE_PADDING;
    lineRect.top = frame.top + this.slideTop;
    lineRect.bottom = (frame.top + this.slideTop) + MIDDLE_LINE_WIDTH;
    canvas.drawBitmap(((BitmapDrawable) getResources().getDrawable(R.drawable.sweep_laser)).getBitmap(), null, lineRect, this.paint);
}
项目:VirtualHook    文件:PendIntentCompat.java   
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) {
        int count = viewGroup.getChildCount();
        Rect p = new Rect();
        viewGroup.getHitRect(p);
        for (int i = 0; i < count; i++) {
            View v = viewGroup.getChildAt(i);
            if (v instanceof ViewGroup) {
                // linearlayout
                setIntentByViewGroup(remoteViews, (ViewGroup) v, list);
            } else if (v instanceof TextView || v instanceof ImageView) {
                // textview
                Rect rect = getRect(v);
                RectInfo next = findIntent(rect, list);
                if (next != null) {
//                  VLog.d(TAG, next.rect+":setPendIntent:"+i);
//                    remoteViews.setImageViewBitmap(v.getId(), next.testBg);
                    remoteViews.setOnClickPendingIntent(v.getId(), next.mPendingIntent);
                }
            }
        }
    }
项目:SmartRefreshLayout    文件:MaterialProgressDrawable.java   
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {
    final RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    arcBounds.inset(mStrokeInset, mStrokeInset);

    final float startAngle = (mStartTrim + mRotation) * 360;
    final float endAngle = (mEndTrim + mRotation) * 360;
    float sweepAngle = endAngle - startAngle;

    if (sweepAngle != 0) {
        mPaint.setColor(mCurrentColor);
        c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
    }

    drawTriangle(c, startAngle, sweepAngle, bounds);

    if (mAlpha < 255) {
        mCirclePaint.setColor(mBackgroundColor);
        mCirclePaint.setAlpha(255 - mAlpha);
        c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
                mCirclePaint);
    }
}
项目:MeiLa_GNN    文件:CameraManager.java   
/**
     * Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
     * not UI / screen.
     */
    public Rect getFramingRectInPreview() {
        if (framingRectInPreview == null) {
            Rect rect = new Rect(getFramingRect());
            Point cameraResolution = configManager.getCameraResolution();
            Point screenResolution = configManager.getScreenResolution();
            //modify here
//      rect.left = rect.left * cameraResolution.x / screenResolution.x;
//      rect.right = rect.right * cameraResolution.x / screenResolution.x;
//      rect.top = rect.top * cameraResolution.y / screenResolution.y;
//      rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
            rect.left = rect.left * cameraResolution.y / screenResolution.x;
            rect.right = rect.right * cameraResolution.y / screenResolution.x;
            rect.top = rect.top * cameraResolution.x / screenResolution.y;
            rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
            framingRectInPreview = rect;
        }
        return framingRectInPreview;
    }
项目:XERUNG    文件:BadgeDrawable.java   
@Override
public void draw(Canvas canvas) {
    if (!mWillDraw) {
        return;
    }

    Rect bounds = getBounds();
    float width = 50;
    float height = 50;

    // Position the badge in the top-right quadrant of the icon.
    float radius = ((Math.min(width, height) / 2) - 1) / 2;
    float centerX = width - radius - 1;
    float centerY = radius + 1;

    // Draw badge circle.
    canvas.drawCircle(centerX, centerY, radius, mBadgePaint);

    // Draw badge count text inside the circle.
    mTextPaint.getTextBounds(mCount, 0, mCount.length(), mTxtRect);
    float textHeight = mTxtRect.bottom - mTxtRect.top;
    float textY = centerY + (textHeight / 2f);
    canvas.drawText(mCount, centerX, textY, mTextPaint);
}
项目:Virtualview-Android    文件:TMReminderTagsView.java   
public TMReminderTagsView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (mDensity == -1) {
        initWith(context);
    }
    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setColor(Color.rgb(255, 59, 68));
    textPaint.setTextSize(dp2px(10));

    bgPaint = new Paint();
    bgPaint.setColor(Color.rgb(250, 211, 213));

    tagsGap = dp2px(7);

    hPadding = dp2px(3);

    tagRect = new Rect();

    textFontMetrics = textPaint.getFontMetrics();
}
项目:RX_Demo    文件:HorizontalDividerItemDecoration.java   
@Override
protected Rect getDividerBound(int position, RecyclerView parent, View child) {
    Rect bounds = new Rect(0, 0, 0, 0);
    int transitionX = (int) ViewCompat.getTranslationX(child);
    int transitionY = (int) ViewCompat.getTranslationY(child);
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
    bounds.left = parent.getPaddingLeft() +
            mMarginProvider.dividerLeftMargin(position, parent) + transitionX;
    bounds.right = parent.getWidth() - parent.getPaddingRight() -
            mMarginProvider.dividerRightMargin(position, parent) + transitionX;

    int dividerSize = getDividerSize(position, parent);
    if (mDividerType == DividerType.DRAWABLE) {
        bounds.top = child.getBottom() + params.topMargin + transitionY;
        bounds.bottom = bounds.top + dividerSize;
    } else {
        bounds.top = child.getBottom() + params.topMargin + dividerSize / 2 + transitionY;
        bounds.bottom = bounds.top;
    }

    return bounds;
}
项目:HeadlineNews    文件:ImageUtils.java   
/**
 * 转为圆形图片
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return 圆形图片
 */
public static Bitmap toRound(final Bitmap src, final boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int radius = Math.min(width, height) >> 1;
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(width >> 1, height >> 1, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
项目:Zxing    文件:ViewfinderView.java   
public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every
    // time in onDraw().
    paint = new Paint();
    Resources resources = getResources();
    maskColor = resources.getColor(R.color.viewfinder_mask);
    resultColor = resources.getColor(R.color.result_view);
    resultPointColor = resources.getColor(R.color.possible_result_points);
    possibleResultPoints = new HashSet<ResultPoint>(5);
    path = new Path();
    lineRect = new Rect();
    /**
     * 获取屏幕密度
     */
    density = context.getResources().getDisplayMetrics().density;
    ScreenRate = (int) (20 * density);
}
项目:qmui    文件:QMUIMaterialProgressDrawable.java   
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {
    final RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    arcBounds.inset(mStrokeInset, mStrokeInset);

    final float startAngle = (mStartTrim + mRotation) * 360;
    final float endAngle = (mEndTrim + mRotation) * 360;
    float sweepAngle = endAngle - startAngle;

    mPaint.setColor(mCurrentColor);
    c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);

    drawTriangle(c, startAngle, sweepAngle, bounds);

    if (mAlpha < 255) {
        mCirclePaint.setColor(mBackgroundColor);
        mCirclePaint.setAlpha(255 - mAlpha);
        c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
                mCirclePaint);
    }
}
项目:Views    文件:SwipeLayout.java   
void layoutLayDown() {
    View surfaceView = getSurfaceView();
    Rect surfaceRect = mViewBoundCache.get(surfaceView);
    if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
    if (surfaceView != null) {
        surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
        bringChildToFront(surfaceView);
    }
    View currentBottomView = getCurrentBottomView();
    Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
    if (bottomViewRect == null)
        bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.LayDown, surfaceRect);
    if (currentBottomView != null) {
        currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
    }
}
项目:InfiniteTabsView    文件:TabLayoutManager.java   
/**
 * Fill right of the center view
 *
 * @param recycler
 * @param startPosition start position to fill right
 * @param startOffset   layout start offset
 * @param rightEdge
 */
private void fillRight(RecyclerView.Recycler recycler, int startPosition, int startOffset, int rightEdge) {
    View scrap;
    int topOffset;
    int scrapWidth, scrapHeight;
    Rect scrapRect = new Rect();
    int height = getVerticalSpace();
    for (int i = startPosition; i < getItemCount() && startOffset < rightEdge; i++) {
        scrap = recycler.getViewForPosition(i);
        addView(scrap);
        measureChildWithMargins(scrap, 0, 0);
        scrapWidth = getDecoratedMeasuredWidth(scrap);
        scrapHeight = getDecoratedMeasuredHeight(scrap);
        topOffset = (int) (getPaddingTop() + (height - scrapHeight) / 2.0f);
        scrapRect.set(startOffset, topOffset, startOffset + scrapWidth, topOffset + scrapHeight);
        layoutDecorated(scrap, scrapRect.left, scrapRect.top, scrapRect.right, scrapRect.bottom);
        startOffset = scrapRect.right;
        mLastVisiblePos = i;
        if (getState().mItemsFrames.get(i) == null) {
            getState().mItemsFrames.put(i, scrapRect);
        } else {
            getState().mItemsFrames.get(i).set(scrapRect);
        }
    }
}
项目:GitHub    文件:ChargeAmountDividerDecoration.java   
@Override
        public void getItemOffsets(Rect outRect, View view,
                                   RecyclerView parent, RecyclerView.State state) {
//            outRect.left = space;
//            outRect.right = space;
//            outRect.bottom = space;
            outRect.set(0, 20, 20, 20);


            // Add top margin only for the first item to avoid double space between items
//            if (parent.getChildLayoutPosition(view) == 0) {
//                outRect.top = space;
//            } else {
//                outRect.top = 0;
//            }
        }
项目:stynico    文件:bilibili.java   
private Bitmap getCircleBitmap(final int radius)
{
       final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
       final Canvas canvas = new Canvas(output);
       final Paint paint = new Paint();
       final Rect rect = new Rect((int)(x - radius), (int)(y - radius), (int)(x + radius), (int)(y + radius));

       paint.setAntiAlias(true);
       canvas.drawARGB(0, 0, 0, 0);
       canvas.drawCircle(x, y, radius, paint);

       paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
       canvas.drawBitmap(originBitmap, rect, rect, paint);

       return output;
   }
项目:Lunary-Ethereum-Wallet    文件:Blockies.java   
public static Bitmap getCroppedBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
项目:letv    文件:NestedScrollView.java   
public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mTempRect = new Rect();
    this.mIsLayoutDirty = true;
    this.mIsLaidOut = false;
    this.mChildToScrollTo = null;
    this.mIsBeingDragged = false;
    this.mSmoothScrollingEnabled = true;
    this.mActivePointerId = -1;
    this.mScrollOffset = new int[2];
    this.mScrollConsumed = new int[2];
    initScrollView();
    TypedArray a = context.obtainStyledAttributes(attrs, SCROLLVIEW_STYLEABLE, defStyleAttr, 0);
    setFillViewport(a.getBoolean(0, false));
    a.recycle();
    this.mParentHelper = new NestedScrollingParentHelper(this);
    this.mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE);
}
项目:stynico    文件:SunLineView.java   
private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
项目:PlusGram    文件:RecyclerView.java   
Rect getItemDecorInsetsForChild(View child) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (!lp.mInsetsDirty) {
        return lp.mDecorInsets;
    }

    final Rect insets = lp.mDecorInsets;
    insets.set(0, 0, 0, 0);
    final int decorCount = mItemDecorations.size();
    for (int i = 0; i < decorCount; i++) {
        mTempRect.set(0, 0, 0, 0);
        mItemDecorations.get(i).getItemOffsets(mTempRect, child, this, mState);
        insets.left += mTempRect.left;
        insets.top += mTempRect.top;
        insets.right += mTempRect.right;
        insets.bottom += mTempRect.bottom;
    }
    lp.mInsetsDirty = false;
    return insets;
}
项目:TPlayer    文件:PendIntentCompat.java   
private Rect getRect(View view) {
    Rect rect = new Rect();
    rect.top = view.getTop();
    rect.left = view.getLeft();
    rect.right = view.getRight();
    rect.bottom = view.getBottom();

    ViewParent viewParent = view.getParent();
    if (viewParent != null) {
        if (viewParent instanceof ViewGroup) {
            Rect prect = getRect((ViewGroup) viewParent);
            rect.top += prect.top;
            rect.left += prect.left;
            rect.right += prect.left;
            rect.bottom += prect.top;
        }
    }
    return rect;
}
项目:OSchina_resources_android    文件:SwipeBackLayout.java   
private void drawShadow(Canvas canvas, View child) {
    final Rect childRect = mTmpRect;
    child.getHitRect(childRect);

    if ((mEdgeFlag & EDGE_LEFT) != 0) {
        mShadowLeft.setBounds(childRect.left - mShadowLeft.getIntrinsicWidth(), childRect.top,
                childRect.left, childRect.bottom);
        mShadowLeft.setAlpha((int) (mScrimOpacity * FULL_ALPHA));
        mShadowLeft.draw(canvas);
    }

    if ((mEdgeFlag & EDGE_RIGHT) != 0) {
        mShadowRight.setBounds(childRect.right, childRect.top,
                childRect.right + mShadowRight.getIntrinsicWidth(), childRect.bottom);
        mShadowRight.setAlpha((int) (mScrimOpacity * FULL_ALPHA));
        mShadowRight.draw(canvas);
    }

    if ((mEdgeFlag & EDGE_BOTTOM) != 0) {
        mShadowBottom.setBounds(childRect.left, childRect.bottom, childRect.right,
                childRect.bottom + mShadowBottom.getIntrinsicHeight());
        mShadowBottom.setAlpha((int) (mScrimOpacity * FULL_ALPHA));
        mShadowBottom.draw(canvas);
    }
}
项目:PeSanKita-android    文件:StickyHeaderDecoration.java   
/**
 * {@inheritDoc}
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                           RecyclerView.State state)
{
  int position     = parent.getChildAdapterPosition(view);
  int headerHeight = 0;

  if (position != RecyclerView.NO_POSITION && hasHeader(parent, adapter, position)) {
    View header = getHeader(parent, adapter, position).itemView;
    headerHeight = getHeaderHeightForLayout(header);
  }

  outRect.set(0, headerHeight, 0, 0);
}
项目:DateTimePicker    文件:NumberPicker.java   
private void scaleRect(Rect rect, float scale) {
    if (scale != 1.0f) {
        rect.left = (int) (rect.left * scale + 0.5f);
        rect.top = (int) (rect.top * scale + 0.5f);
        rect.right = (int) (rect.right * scale + 0.5f);
        rect.bottom = (int) (rect.bottom * scale + 0.5f);
    }
}
项目:RLibrary    文件:RExItemDecoration.java   
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    final RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();//布局管理器
    final RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
    final int viewLayoutPosition = layoutParams.getViewLayoutPosition();//布局时当前View的位置
    final int viewAdapterPosition = layoutParams.getViewAdapterPosition();

    getItemOffsets(outRect, layoutManager, viewAdapterPosition, getEdge(viewAdapterPosition, layoutManager));
}
项目:ChatExchange-old    文件:CustomViewAbove.java   
private boolean isInIgnoredView(MotionEvent ev)
{
    Rect rect = new Rect();
    for (View v : mIgnoredViews)
    {
        v.getHitRect(rect);
        if (rect.contains((int) ev.getX(), (int) ev.getY()))
        {
            return true;
        }
    }
    return false;
}
项目:Huochexing12306    文件:ShareUtil.java   
/**
 * 保存截图到sd卡 并返回截图路径
 * @param activity
 * @return
 */
public String getScreenShut(Activity activity){
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap b1 = view.getDrawingCache();
    // 获取状态栏高度
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    int statusBarHeight = frame.top;
    // 获取屏幕长和高
    int width = activity.getWindowManager().getDefaultDisplay().getWidth();
    int height = activity.getWindowManager().getDefaultDisplay()
            .getHeight();
    // 去掉标题栏
    Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height
            - statusBarHeight);
    view.destroyDrawingCache();
    //保存到sd卡
    String  sdCardRoot = Environment.getExternalStorageDirectory().getAbsolutePath();
    String fileName = "shareIMG"+new Date().getTime()+".png";
    String path = sdCardRoot+"/HuoCheXing/shareImage/"+fileName;
    if(saveBitmapToSDCard(b,path)){
        return path;
    }
    return null;
}
项目:SimpleUILauncher    文件:DragPreviewProvider.java   
protected static Rect getDrawableBounds(Drawable d) {
    Rect bounds = new Rect();
    d.copyBounds(bounds);
    if (bounds.width() == 0 || bounds.height() == 0) {
        bounds.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
    } else {
        bounds.offsetTo(0, 0);
    }
    if (d instanceof PreloadIconDrawable) {
        int inset = -((PreloadIconDrawable) d).getOutset();
        bounds.inset(inset, inset);
    }
    return bounds;
}
项目:AndroidDigIn    文件:TouchDelegateViewGroup.java   
public void setDelegateAreaColor(@ColorInt int color, Rect rect) {
    paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(color);
    this.rect = rect;
    invalidate();
}
项目:LaunchEnr    文件:ClickShadowView.java   
/**
 * Aligns the shadow with {@param view}
 * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
 */
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
    float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
    float topShift = view.getTop() + viewParent.getTop() - getTop();
    int iconWidth = view.getRight() - view.getLeft();
    int iconHeight = view.getBottom() - view.getTop();
    int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    float drawableWidth = view.getIcon().getBounds().width();

    if (clipAgainstView != null) {
        // Set the bounds to clip against
        int[] coords = new int[] {0, 0};
        Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
                coords, false);
        int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
        int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
        setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
    } else {
        // Reset the clip bounds
        setClipBounds(null);
    }

    setTranslationX(leftShift
            + viewParent.getTranslationX()
            + view.getCompoundPaddingLeft() * view.getScaleX()
            + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
            + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
    setTranslationY(topShift
            + viewParent.getTranslationY()
            + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
            + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
}