@SuppressWarnings("NullableProblems")
  @Override
  protected void onDraw(Canvas canvas) {

    // Draw Title Text
    if (mAttributes.isShowTitle()
        && mTitlePaint != null
        && mCurTitleProperty != null
        && mCurTitleProperty.mAlpha != 0) {
      CharSequence buf = getHint();
      if (buf != null) {
        mTitlePaint.setTextSize(mCurTitleProperty.mTextSize);

        int color = getCurrentTitleTextColor();
        int alpha = GeniusUi.modulateAlpha(Color.alpha(color), mCurTitleProperty.mAlpha);

        mTitlePaint.setColor(color);
        mTitlePaint.setAlpha(alpha);

        canvas.drawText(
            buf,
            0,
            buf.length(),
            mCurTitleProperty.mPaddingLeft,
            mCurTitleProperty.mPaddingTop + mCurTitleProperty.mTextSize,
            mTitlePaint);
      }
    }

    super.onDraw(canvas);
  }
Exemple #2
0
 /**
  * Set the draw paint alpha by modulateAlpha
  *
  * @param paint Paint
  * @param alpha Alpha
  * @return PrevAlpha
  */
 protected int setPaintAlpha(Paint paint, int alpha) {
   final int prevAlpha = paint.getAlpha();
   paint.setAlpha(GeniusUi.modulateAlpha(prevAlpha, alpha));
   return prevAlpha;
 }