Esempio n. 1
0
  private void init() {
    mWhitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mWhitePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mWhitePaint.setStrokeWidth(Helper.dpToPixel(0.1f, getContext()));
    mWhitePaint.setColor(Color.WHITE);

    mGreyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mGreyPaint.setStyle(Paint.Style.STROKE);
    mGreyPaint.setStrokeWidth(Helper.dpToPixel(2, getContext()));
    mGreyPaint.setColor(Color.WHITE);

    mBound = new RectF();
  }
Esempio n. 2
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   float mAngle = mProgress * 360f / mMax;
   canvas.drawArc(mBound, 270, mAngle, true, mWhitePaint);
   int padding = Helper.dpToPixel(4, getContext());
   canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 2 - padding, mGreyPaint);
 }
Esempio n. 3
0
 private void updateBackgroundSize() {
   ViewGroup.LayoutParams params = mBackgroundLayout.getLayoutParams();
   params.width = Helper.dpToPixel(mWidth, getContext());
   params.height = Helper.dpToPixel(mHeight, getContext());
   mBackgroundLayout.setLayoutParams(params);
 }
Esempio n. 4
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int dimension = Helper.dpToPixel(40, getContext());
   setMeasuredDimension(dimension, dimension);
 }
Esempio n. 5
0
 @Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
   super.onSizeChanged(w, h, oldw, oldh);
   int padding = Helper.dpToPixel(4, getContext());
   mBound.set(padding, padding, w - padding, h - padding);
 }
 public void setCornerRadius(float radius) {
   mCornerRadius = Helper.dpToPixel(radius, getContext());
   initBackground(mBackgroundColor, mCornerRadius);
 }