Esempio n. 1
0
  @Override
  protected void dispatchDraw(Canvas canvas) {
    if (mShowcaseX < 0 || mShowcaseY < 0 || mIsRedundant) {
      super.dispatchDraw(canvas);
      return;
    }

    boolean recalculatedCling = mShowcaseDrawer.calculateShowcaseRect(mShowcaseX, mShowcaseY);
    boolean recalculateText = recalculatedCling || mAlteredText;
    mAlteredText = false;

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && !mHasNoTarget) {
      Path path = new Path();
      path.addCircle(mShowcaseX, mShowcaseY, mShowcaseRadius, Path.Direction.CW);
      canvas.clipPath(path, Op.DIFFERENCE);
    }

    // Draw background color
    canvas.drawColor(mBackgroundColor);

    // Draw the showcase drawable
    if (!mHasNoTarget) {
      mShowcaseDrawer.drawShowcase(
          canvas, mShowcaseX, mShowcaseY, mScaleMultiplier, mShowcaseRadius);
    }

    // Draw the text on the screen, recalculating its position if necessary
    if (recalculateText) {
      mTextDrawer.calculateTextPosition(canvas.getWidth(), canvas.getHeight(), this);
    }
    mTextDrawer.draw(canvas, recalculateText);

    super.dispatchDraw(canvas);
  }