use of android.graphics.Paint in project UltimateAndroid by cymcsg.
the class CirclesDrawable method initCirclesProgress.
private void initCirclesProgress(int[] colors) {
initColors(colors);
mPath = new Path();
Paint basePaint = new Paint();
basePaint.setAntiAlias(true);
mFstHalfPaint = new Paint(basePaint);
mScndHalfPaint = new Paint(basePaint);
mAbovePaint = new Paint(basePaint);
setColorFilter(mColorFilter);
}
use of android.graphics.Paint in project UltimateAndroid by cymcsg.
the class RippleDrawable method drawRippleLayer.
private int drawRippleLayer(Canvas canvas, Rect bounds, PorterDuffXfermode mode) {
boolean drewRipples = false;
int restoreToCount = -1;
int restoreTranslate = -1;
// Draw ripples and update the animating ripples array.
final int count = mExitingRipplesCount;
final Ripple[] ripples = mExitingRipples;
for (int i = 0; i <= count; i++) {
final Ripple ripple;
if (i < count) {
ripple = ripples[i];
} else if (mRipple != null) {
ripple = mRipple;
} else {
continue;
}
// first. This will merge SRC_OVER (directly) onto the canvas.
if (restoreToCount < 0) {
final Paint maskingPaint = getMaskingPaint(mode);
final int color = mColor.getColorForState(getState(), Color.TRANSPARENT);
final int alpha = Color.alpha(color);
maskingPaint.setAlpha(alpha / 2);
// Translate the canvas to the current hotspot bounds.
restoreTranslate = canvas.save();
canvas.translate(mHotspotBounds.exactCenterX(), mHotspotBounds.exactCenterY());
}
drewRipples |= ripple.draw(canvas, getRipplePaint());
}
// Always restore the translation.
if (restoreTranslate >= 0) {
canvas.restoreToCount(restoreTranslate);
}
// If we created a layer with no content, merge it immediately.
if (restoreToCount >= 0 && !drewRipples) {
canvas.restoreToCount(restoreToCount);
restoreToCount = -1;
}
return restoreToCount;
}
use of android.graphics.Paint in project UltimateAndroid by cymcsg.
the class IconPainter method init.
private void init() {
paint = new Paint();
paint.setAntiAlias(true);
initBitmap();
}
use of android.graphics.Paint in project UltimateAndroid by cymcsg.
the class MaterialTab method getTextLenght.
private int getTextLenght() {
String textString = text.getText().toString();
Rect bounds = new Rect();
Paint textPaint = text.getPaint();
textPaint.getTextBounds(textString, 0, textString.length(), bounds);
return bounds.width();
}
use of android.graphics.Paint in project UltimateAndroid by cymcsg.
the class TitlePageIndicator method calculateAllBounds.
/**
* Calculate views bounds and scroll them according to the current index
*
* @param paint
* @return
*/
private ArrayList<Rect> calculateAllBounds(Paint paint) {
ArrayList<Rect> list = new ArrayList<Rect>();
//For each views (If no values then add a fake one)
final int count = mViewPager.getAdapter().getCount();
final int width = getWidth();
final int halfWidth = width / 2;
for (int i = 0; i < count; i++) {
Rect bounds = calcBounds(i, paint);
int w = bounds.right - bounds.left;
int h = bounds.bottom - bounds.top;
bounds.left = (int) (halfWidth - (w / 2f) + ((i - mCurrentPage - mPageOffset) * width));
bounds.right = bounds.left + w;
bounds.top = 0;
bounds.bottom = h;
list.add(bounds);
}
return list;
}
Aggregations