Search in sources :

Example 76 with Rect

use of android.graphics.Rect in project Carbon by ZieIony.

the class RippleDrawableFroyo method getDirtyBounds.

@Override
public Rect getDirtyBounds() {
    if (!isBounded()) {
        final Rect drawingBounds = mDrawingBounds;
        final Rect dirtyBounds = mDirtyBounds;
        dirtyBounds.set(drawingBounds);
        drawingBounds.setEmpty();
        final int cX = (int) mHotspotBounds.exactCenterX();
        final int cY = (int) mHotspotBounds.exactCenterY();
        final Rect rippleBounds = mTempRect;
        final RippleForeground[] activeRipples = mExitingRipples;
        final int N = mExitingRipplesCount;
        for (int i = 0; i < N; i++) {
            activeRipples[i].getBounds(rippleBounds);
            rippleBounds.offset(cX, cY);
            drawingBounds.union(rippleBounds);
        }
        final RippleBackground background = mBackground;
        if (background != null) {
            background.getBounds(rippleBounds);
            rippleBounds.offset(cX, cY);
            drawingBounds.union(rippleBounds);
        }
        dirtyBounds.union(drawingBounds);
        if (Build.VERSION.SDK_INT >= 21)
            dirtyBounds.union(super.getDirtyBounds());
        return dirtyBounds;
    } else {
        return getBounds();
    }
}
Also used : Rect(android.graphics.Rect) Paint(android.graphics.Paint)

Example 77 with Rect

use of android.graphics.Rect in project remusic by aa112901.

the class PlayerSeekBar method setThumb.

@Override
public void setThumb(Drawable thumb) {
    Rect localRect = null;
    if (drawable != null) {
        localRect = drawable.getBounds();
    }
    super.setThumb(drawable);
    drawable = thumb;
    if ((localRect != null) && (drawable != null)) {
        drawable.setBounds(localRect);
    }
}
Also used : Rect(android.graphics.Rect)

Example 78 with Rect

use of android.graphics.Rect in project actor-platform by actorapp.

the class BubbleTextContainer method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Rect bounds = new Rect();
    Drawable background = getBackground();
    if (background != null) {
        background.getPadding(bounds);
    }
    int wMode = MeasureSpec.getMode(widthMeasureSpec);
    int maxW = MeasureSpec.getSize(widthMeasureSpec) - bounds.left - bounds.right;
    TextView messageView = (TextView) getChildAt(0);
    messageView.measure(MeasureSpec.makeMeasureSpec(maxW, wMode), heightMeasureSpec);
    View timeView = getChildAt(1);
    timeView.measure(MeasureSpec.makeMeasureSpec(maxW, wMode), heightMeasureSpec);
    Layout textLayout = messageView.getLayout();
    int contentW = messageView.getMeasuredWidth();
    int timeW = timeView.getMeasuredWidth();
    boolean isRtl = BidiFormatter.getInstance().isRtl(messageView.getText().toString());
    if (messageView.getLayout().getLineCount() < 5 && !isRtl) {
        contentW = 0;
        for (int i = 0; i < textLayout.getLineCount(); i++) {
            contentW = Math.max(contentW, (int) textLayout.getLineWidth(i));
        }
    }
    int lastLineW = (int) textLayout.getLineWidth(textLayout.getLineCount() - 1);
    if (isRtl) {
        lastLineW = contentW;
    }
    int fullContentW, fullContentH;
    if (isRtl) {
        fullContentW = contentW;
        fullContentH = messageView.getMeasuredHeight() + timeView.getMeasuredHeight();
    } else {
        if (lastLineW + timeW < contentW) {
            // Nothing to do
            fullContentW = contentW;
            fullContentH = messageView.getMeasuredHeight();
        } else if (lastLineW + timeW < maxW) {
            fullContentW = lastLineW + timeW;
            fullContentH = messageView.getMeasuredHeight();
        } else {
            fullContentW = contentW;
            fullContentH = messageView.getMeasuredHeight() + timeView.getMeasuredHeight();
        }
    }
    setMeasuredDimension(fullContentW + bounds.left + bounds.right, fullContentH + bounds.top + bounds.bottom);
}
Also used : Rect(android.graphics.Rect) Layout(android.text.Layout) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 79 with Rect

use of android.graphics.Rect in project actor-platform by actorapp.

the class TypingDrawable method draw.

@Override
public void draw(Canvas canvas) {
    float size1 = 0.7f + (0.3f * process(ANIMATION_OFFSET * 2));
    float size2 = 0.7f + (0.3f * process(ANIMATION_OFFSET));
    float size3 = 0.7f + (0.3f * process(0));
    Rect bounds = getBounds();
    int top = ((getBounds().height() - Screen.dp(DIAMETER)) / 2) + bounds.top;
    canvas.drawCircle(Screen.dp(RADIUS), Screen.dp(RADIUS) + top, size1 * Screen.dp(RADIUS), paint);
    canvas.drawCircle(Screen.dp(RADIUS + DIAMETER + OFFSET), Screen.dp(RADIUS) + top, size2 * Screen.dp(RADIUS), paint);
    canvas.drawCircle(Screen.dp(RADIUS + (DIAMETER + OFFSET) * 2), Screen.dp(RADIUS) + top, size3 * Screen.dp(RADIUS), paint);
    invalidateSelf();
}
Also used : Rect(android.graphics.Rect) Paint(android.graphics.Paint)

Example 80 with Rect

use of android.graphics.Rect in project actor-platform by actorapp.

the class AvatarPlaceholderDrawable method setBounds.

@Override
public void setBounds(int left, int top, int right, int bottom) {
    super.setBounds(left, top, right, bottom);
    Rect bounds = new Rect();
    if (TEXT_SIZE != selfTextSize) {
        TEXT_PAINT.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, selfTextSize, ctx.getResources().getDisplayMetrics()));
        TEXT_SIZE = selfTextSize;
    }
    textX = (int) ((right - left - (TEXT_PAINT).measureText(title, 0, title.length())) / 2);
    (TEXT_PAINT).getTextBounds(title, 0, title.length(), bounds);
    textY = (int) ((bottom - top - bounds.top - bounds.bottom) / 2);
}
Also used : Rect(android.graphics.Rect)

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