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();
}
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations