Search in sources :

Example 86 with Rect

use of android.graphics.Rect in project SuperSLiM by TonicArtos.

the class LayoutManager method layoutHeaderTowardsEnd.

/**
     * Layout header for fill to end.
     *
     * @param header     Header to be laid out.
     * @param markerLine Start of section.
     * @param sd         Section data.
     * @param state      Layout state.
     * @return Line at which to start filling out the section's content.
     */
private int layoutHeaderTowardsEnd(View header, int markerLine, SectionData sd, LayoutState state) {
    Rect r = setHeaderRectSides(mRect, sd, state);
    r.top = markerLine;
    r.bottom = r.top + sd.headerHeight;
    if (sd.headerParams.isHeaderInline() && !sd.headerParams.isHeaderOverlay()) {
        markerLine = r.bottom;
    }
    if (sd.headerParams.isHeaderSticky() && r.top < 0) {
        r.top = 0;
        r.bottom = r.top + sd.headerHeight;
    }
    layoutDecorated(header, r.left, r.top, r.right, r.bottom);
    return markerLine;
}
Also used : Rect(android.graphics.Rect)

Example 87 with Rect

use of android.graphics.Rect in project BoomMenu by Nightonke.

the class BoomButton method initAttrs.

protected void initAttrs(BoomButtonBuilder builder) {
    index = builder.index;
    listener = builder.listener;
    onBMClickListener = builder.onBMClickListener;
    rotateImage = builder.rotateImage;
    rotateText = builder.rotateText;
    containsSubText = builder.containsSubText;
    pieceColor = builder.pieceColor;
    pieceColorRes = builder.pieceColorRes;
    shadowEffect = builder.shadowEffect;
    if (shadowEffect) {
        shadowOffsetX = builder.shadowOffsetX;
        shadowOffsetY = builder.shadowOffsetY;
        shadowRadius = builder.shadowRadius;
        shadowCornerRadius = builder.shadowCornerRadius;
        shadowColor = builder.shadowColor;
    }
    normalImageRes = builder.normalImageRes;
    highlightedImageRes = builder.highlightedImageRes;
    unableImageRes = builder.unableImageRes;
    normalImageDrawable = builder.normalImageDrawable;
    highlightedImageDrawable = builder.highlightedImageDrawable;
    unableImageDrawable = builder.unableImageDrawable;
    imageRect = builder.imageRect;
    imagePadding = builder.imagePadding;
    normalTextRes = builder.normalTextRes;
    highlightedTextRes = builder.highlightedTextRes;
    unableTextRes = builder.unableTextRes;
    normalText = builder.normalText;
    highlightedText = builder.highlightedText;
    unableText = builder.unableText;
    normalTextColor = builder.normalTextColor;
    highlightedTextColor = builder.highlightedTextColor;
    unableTextColor = builder.unableTextColor;
    textRect = builder.textRect;
    textPadding = builder.textPadding;
    typeface = builder.typeface;
    maxLines = builder.maxLines;
    textGravity = builder.textGravity;
    ellipsize = builder.ellipsize;
    textSize = builder.textSize;
    subNormalTextRes = builder.subNormalTextRes;
    subHighlightedTextRes = builder.subHighlightedTextRes;
    subUnableTextRes = builder.subUnableTextRes;
    subNormalText = builder.subNormalText;
    subHighlightedText = builder.subHighlightedText;
    subUnableText = builder.subUnableText;
    subNormalTextColor = builder.subNormalTextColor;
    subHighlightedTextColor = builder.subHighlightedTextColor;
    subUnableTextColor = builder.subUnableTextColor;
    subTextRect = builder.subTextRect;
    subTextPadding = builder.subTextPadding;
    subTypeface = builder.subTypeface;
    subMaxLines = builder.subMaxLines;
    subTextGravity = builder.subTextGravity;
    subEllipsize = builder.subEllipsize;
    subTextSize = builder.subTextSize;
    rippleEffect = builder.rippleEffect;
    normalColor = builder.normalColor;
    normalColorRes = builder.normalColorRes;
    highlightedColor = builder.highlightedColor;
    highlightedColorRes = builder.highlightedColorRes;
    unableColor = builder.unableColor;
    unableColorRes = builder.unableColorRes;
    unable = builder.unable;
    buttonRadius = builder.buttonRadius;
    buttonWidth = builder.buttonWidth;
    buttonHeight = builder.buttonHeight;
    buttonCornerRadius = builder.buttonCornerRadius;
    rippleEffectWorks = rippleEffect && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
    // for text-outside-circle-button
    textTopMargin = builder.textTopMargin;
    textWidth = builder.textWidth;
    textHeight = builder.textHeight;
    if (builder instanceof TextOutsideCircleButton.Builder) {
        int buttonAndShadowWidth = buttonRadius * 2 + shadowOffsetX * 2 + shadowRadius * 2;
        if (textWidth > buttonAndShadowWidth) {
            textRect = new Rect(0, shadowOffsetY + shadowRadius + buttonRadius * 2 + textTopMargin, textWidth, shadowOffsetY + shadowRadius + buttonRadius * 2 + textTopMargin + textHeight);
        } else {
            textRect = new Rect((buttonAndShadowWidth - textWidth) / 2, shadowOffsetY + shadowRadius + buttonRadius * 2 + textTopMargin, (buttonAndShadowWidth - textWidth) / 2 + textWidth, shadowOffsetY + shadowRadius + buttonRadius * 2 + textTopMargin + textHeight);
        }
        trueRadius = (int) (Util.distance(new Point(shadowOffsetX + shadowRadius + buttonRadius, shadowOffsetY + shadowRadius + buttonRadius), new Point(textRect.right, textRect.bottom)) + 1);
        if (textWidth > buttonAndShadowWidth)
            textRect.offset(trueRadius - textWidth / 2, trueRadius - (shadowOffsetY + shadowRadius + buttonRadius));
        else
            textRect.offset(trueRadius - (shadowOffsetX + shadowRadius + buttonRadius), trueRadius - (shadowOffsetY + shadowRadius + buttonRadius));
    }
}
Also used : Rect(android.graphics.Rect) Point(android.graphics.Point) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint)

Example 88 with Rect

use of android.graphics.Rect in project mounts2sd by SpazeDog.

the class ViewEventHandler method onTouch.

@Override
public boolean onTouch(View v, MotionEvent event) {
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStatePressedRunnable.begin(v);
        mEventDown = true;
        mRect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        return true;
    /* ACTION_CANCEL, ACTION_OUTSIDE and such is not used with newer Android versions, 
			 * here we use the mRect check instead. However, you need the other in order to fix conflicts with older versions. 
			 */
    } else if (mEventDown && (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL || event.getActionMasked() == MotionEvent.ACTION_SCROLL || event.getActionMasked() == MotionEvent.ACTION_OUTSIDE || !mRect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY()))) {
        mStatePressedRunnable.cancel();
        if (mEventDown && event.getActionMasked() == MotionEvent.ACTION_UP) {
            mEventDown = false;
            mStateClickedRunnable.begin(v);
            return true;
        }
        v.setPressed((mEventDown = false));
    }
    return false;
}
Also used : Rect(android.graphics.Rect)

Example 89 with Rect

use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.

the class NavigationBarView method dump.

public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    pw.println("NavigationBarView {");
    final Rect r = new Rect();
    final Point size = new Point();
    mDisplay.getRealSize(size);
    pw.println(String.format("      this: " + PhoneStatusBar.viewInfo(this) + " " + visibilityToString(getVisibility())));
    getWindowVisibleDisplayFrame(r);
    final boolean offscreen = r.right > size.x || r.bottom > size.y;
    pw.println("      window: " + r.toShortString() + " " + visibilityToString(getWindowVisibility()) + (offscreen ? " OFFSCREEN!" : ""));
    pw.println(String.format("      mCurrentView: id=%s (%dx%d) %s", getResourceName(mCurrentView.getId()), mCurrentView.getWidth(), mCurrentView.getHeight(), visibilityToString(mCurrentView.getVisibility())));
    pw.println(String.format("      disabled=0x%08x vertical=%s hidden=%s low=%s menu=%s", mDisabledFlags, mVertical ? "true" : "false", mHidden ? "true" : "false", mLowProfile ? "true" : "false", mShowMenu ? "true" : "false"));
    final View back = getBackButton();
    final View home = getHomeButton();
    final View recent = getRecentsButton();
    pw.println("      home: " + PhoneStatusBar.viewInfo(home) + " " + visibilityToString(home.getVisibility()));
    if (back != null) {
        pw.println("      back: " + PhoneStatusBar.viewInfo(back) + " " + visibilityToString(back.getVisibility()));
    }
    if (recent != null) {
        pw.println("      recent: " + PhoneStatusBar.viewInfo(recent) + " " + visibilityToString(recent.getVisibility()));
    }
    pw.println("    }");
}
Also used : Rect(android.graphics.Rect) Point(android.graphics.Point) ImageView(android.widget.ImageView) View(android.view.View)

Example 90 with Rect

use of android.graphics.Rect in project android_frameworks_base by ParanoidAndroid.

the class NotificationLinearLayout method onDraw.

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    final Rect padding = mTmp;
    final Drawable glow = mItemGlow;
    glow.getPadding(padding);
    final int glowHeight = glow.getIntrinsicHeight();
    final int insetLeft = mInsetLeft;
    final int N = getChildCount();
    for (int i = 0; i < N; i++) {
        final View child = getChildAt(i);
        final int childBottom = child.getBottom();
        glow.setBounds(child.getLeft() - padding.left + insetLeft, childBottom, child.getRight() - padding.right, childBottom + glowHeight);
        glow.draw(canvas);
    }
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Rect (android.graphics.Rect)4805 Paint (android.graphics.Paint)1052 View (android.view.View)687 Point (android.graphics.Point)563 Bitmap (android.graphics.Bitmap)467 Canvas (android.graphics.Canvas)372 RectF (android.graphics.RectF)266 Drawable (android.graphics.drawable.Drawable)241 Matrix (android.graphics.Matrix)125 ViewGroup (android.view.ViewGroup)121 ArrayList (java.util.ArrayList)121 TextView (android.widget.TextView)119 SuppressLint (android.annotation.SuppressLint)116 Resources (android.content.res.Resources)112 TextPaint (android.text.TextPaint)110 PorterDuffXfermode (android.graphics.PorterDuffXfermode)105 ImageView (android.widget.ImageView)97 BitmapDrawable (android.graphics.drawable.BitmapDrawable)95 SmallTest (android.test.suitebuilder.annotation.SmallTest)94 RemoteException (android.os.RemoteException)93