use of android.graphics.Rect in project glitch-hq-android by tinyspeck.
the class KeyboardLayout method onMeasure.
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int errorState = this.findViewById(R.id.tv_login_error).getVisibility();
if (errorState != m_lastErrorState) {
m_lastErrorState = errorState;
} else {
final int height = MeasureSpec.getSize(heightMeasureSpec);
Activity activity = (Activity) getContext();
Rect rect = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
final int statusBarHeight = rect.top;
final int screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight();
final int diff = (screenHeight - statusBarHeight) - height;
// Assume all soft keyboards are at least 128 pixels high
if (diff > 128) {
// Keyboard is shown
this.findViewById(R.id.copyright).setVisibility(View.GONE);
} else {
// Keyboard is hidden
this.findViewById(R.id.copyright).setVisibility(View.VISIBLE);
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
use of android.graphics.Rect in project enroscar by stanfy.
the class CropStartDecorator method processBitmap.
@Override
protected Bitmap processBitmap(final Bitmap bitmap, final Canvas canvas) {
final Rect srcBounds = this.srcBounds, dstBounds = this.dstBounds;
final int w = fitSourcePolicy ? Math.min(bitmap.getWidth(), dstBounds.right) : dstBounds.right;
final int h = fitSourcePolicy ? Math.min(bitmap.getHeight(), dstBounds.bottom) : dstBounds.bottom;
srcBounds.set(0, 0, w, h);
bitmapCanvas.drawBitmap(bitmap, srcBounds, dstBounds, null);
return this.bitmap;
}
use of android.graphics.Rect in project sticky-headers-recyclerview by timehop.
the class StickyRecyclerHeadersDecoration method onDrawOver.
@Override
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
super.onDrawOver(canvas, parent, state);
final int childCount = parent.getChildCount();
if (childCount <= 0 || mAdapter.getItemCount() <= 0) {
return;
}
for (int i = 0; i < childCount; i++) {
View itemView = parent.getChildAt(i);
int position = parent.getChildAdapterPosition(itemView);
if (position == RecyclerView.NO_POSITION) {
continue;
}
boolean hasStickyHeader = mHeaderPositionCalculator.hasStickyHeader(itemView, mOrientationProvider.getOrientation(parent), position);
if (hasStickyHeader || mHeaderPositionCalculator.hasNewHeader(position, mOrientationProvider.isReverseLayout(parent))) {
View header = mHeaderProvider.getHeader(parent, position);
//re-use existing Rect, if any.
Rect headerOffset = mHeaderRects.get(position);
if (headerOffset == null) {
headerOffset = new Rect();
mHeaderRects.put(position, headerOffset);
}
mHeaderPositionCalculator.initHeaderBounds(headerOffset, parent, header, itemView, hasStickyHeader);
mRenderer.drawHeader(parent, canvas, header, headerOffset);
}
}
}
use of android.graphics.Rect in project glitch-hq-android by tinyspeck.
the class BitmapUtil method CreateOvalImage.
public static Bitmap CreateOvalImage(Bitmap orgBmp) {
int nW = 60;
int nH = 60;
int nW0 = orgBmp.getWidth();
int nH0 = orgBmp.getHeight();
// Rect r = new Rect();
// r.left = (int) ( nW0 * 0.18 );
// r.top = nH0 / 11;
// r.right = (int) ( nW0 * 0.94 );
// r.bottom = (int) ( nH0 * 0.63 );
Rect r = new Rect();
r.left = 18;
r.top = 16;
r.right = nW0;
r.bottom = 95;
Bitmap bmNew = Bitmap.createBitmap(nW, nH, Bitmap.Config.ARGB_8888);
Canvas cvs = new Canvas(bmNew);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setAlpha(78);
paint.setColor(0xffc0c0c0);
RectF rDest = new RectF();
rDest.left = 1;
rDest.right = nW;
rDest.top = 1;
rDest.bottom = nH;
Path clip = new Path();
clip.addCircle(nW / 2, nH / 2, (float) (nW / 2 + 0.5), Path.Direction.CW);
cvs.clipPath(clip);
cvs.drawARGB(78, 233, 240, 240);
cvs.drawBitmap(orgBmp, r, rDest, paint);
cvs.drawCircle(nW / 2, nH / 2, nW / 2, paint);
return bmNew;
}
use of android.graphics.Rect in project BGAQRCode-Android by bingoogolapple.
the class ScanBoxView method drawTipText.
/**
* 画提示文本
*
* @param canvas
*/
private void drawTipText(Canvas canvas) {
if (TextUtils.isEmpty(mTipText) || mTipTextSl == null) {
return;
}
if (mIsTipTextBelowRect) {
if (mIsShowTipBackground) {
mPaint.setColor(mTipBackgroundColor);
mPaint.setStyle(Paint.Style.FILL);
if (mIsShowTipTextAsSingleLine) {
Rect tipRect = new Rect();
mTipPaint.getTextBounds(mTipText, 0, mTipText.length(), tipRect);
float left = (canvas.getWidth() - tipRect.width()) / 2 - mTipBackgroundRadius;
canvas.drawRoundRect(new RectF(left, mFramingRect.bottom + mTipTextMargin - mTipBackgroundRadius, left + tipRect.width() + 2 * mTipBackgroundRadius, mFramingRect.bottom + mTipTextMargin + mTipTextSl.getHeight() + mTipBackgroundRadius), mTipBackgroundRadius, mTipBackgroundRadius, mPaint);
} else {
canvas.drawRoundRect(new RectF(mFramingRect.left, mFramingRect.bottom + mTipTextMargin - mTipBackgroundRadius, mFramingRect.right, mFramingRect.bottom + mTipTextMargin + mTipTextSl.getHeight() + mTipBackgroundRadius), mTipBackgroundRadius, mTipBackgroundRadius, mPaint);
}
}
canvas.save();
if (mIsShowTipTextAsSingleLine) {
canvas.translate(0, mFramingRect.bottom + mTipTextMargin);
} else {
canvas.translate(mFramingRect.left + mTipBackgroundRadius, mFramingRect.bottom + mTipTextMargin);
}
mTipTextSl.draw(canvas);
canvas.restore();
} else {
if (mIsShowTipBackground) {
mPaint.setColor(mTipBackgroundColor);
mPaint.setStyle(Paint.Style.FILL);
if (mIsShowTipTextAsSingleLine) {
Rect tipRect = new Rect();
mTipPaint.getTextBounds(mTipText, 0, mTipText.length(), tipRect);
float left = (canvas.getWidth() - tipRect.width()) / 2 - mTipBackgroundRadius;
canvas.drawRoundRect(new RectF(left, mFramingRect.top - mTipTextMargin - mTipTextSl.getHeight() - mTipBackgroundRadius, left + tipRect.width() + 2 * mTipBackgroundRadius, mFramingRect.top - mTipTextMargin + mTipBackgroundRadius), mTipBackgroundRadius, mTipBackgroundRadius, mPaint);
} else {
canvas.drawRoundRect(new RectF(mFramingRect.left, mFramingRect.top - mTipTextMargin - mTipTextSl.getHeight() - mTipBackgroundRadius, mFramingRect.right, mFramingRect.top - mTipTextMargin + mTipBackgroundRadius), mTipBackgroundRadius, mTipBackgroundRadius, mPaint);
}
}
canvas.save();
if (mIsShowTipTextAsSingleLine) {
canvas.translate(0, mFramingRect.top - mTipTextMargin - mTipTextSl.getHeight());
} else {
canvas.translate(mFramingRect.left + mTipBackgroundRadius, mFramingRect.top - mTipTextMargin - mTipTextSl.getHeight());
}
mTipTextSl.draw(canvas);
canvas.restore();
}
}
Aggregations