@Override
    protected void onBoundsChange(Rect bounds) {
      super.onBoundsChange(bounds);

      if (isCanvasRectEmpty()) {
        path = Optional.absent();
        backgroundPaint.setShader(null);
        return;
      }

      path = Optional.of(pathFactory.newInstance(bounds));
      backgroundPaint.setShader(
          new LinearGradient(
              0, bounds.top, 0, bounds.bottom - 1, topColor, bottomColor, TileMode.CLAMP));
    }