@Override
  protected Drawable getDrawable(int rank, int itemState) {
    if (mDrawableRightButton != null && mDrawableRightButton.length >= 3) {
      int idxDrawable = 0;
      if (NMapOverlayItem.isPressedState(itemState)) {
        idxDrawable = 1;
      } else if (NMapOverlayItem.isSelectedState(itemState)) {
        idxDrawable = 2;
      } else if (NMapOverlayItem.isFocusedState(itemState)) {
        idxDrawable = 2;
      }
      Drawable drawable = mDrawableRightButton[idxDrawable];
      return drawable;
    }

    return null;
  }
  public NMapCalloutCustomOverlayView(
      Context context, NMapOverlay itemOverlay, NMapOverlayItem item, Rect itemBounds) {
    super(context, itemOverlay, item, itemBounds);

    String infService = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater li = (LayoutInflater) getContext().getSystemService(infService);
    li.inflate(R.layout.map_callout_overlay_view, this, true);

    mCalloutView = findViewById(R.id.callout_overlay);
    mCalloutText = (TextView) mCalloutView.findViewById(R.id.callout_text);
    mRightArrow = findViewById(R.id.callout_rightArrow);

    mCalloutView.setOnClickListener(callOutClickListener);

    mCalloutText.setText(item.getTitle());

    if (item instanceof NMapPOIitem) {
      if (((NMapPOIitem) item).hasRightAccessory() == false) {
        mRightArrow.setVisibility(View.GONE);
      }
    }
  }
  public NMapCalloutCustomOldOverlay(
      NMapOverlay itemOverlay,
      NMapOverlayItem item,
      Rect itemBounds,
      NMapCalloutCustomOldOverlay.ResourceProvider resourceProvider) {

    super(itemOverlay, item, itemBounds);

    mTextPaint.setAntiAlias(true);
    // set font style
    mTextPaint.setColor(CALLOUT_TEXT_COLOR);
    // set font size
    mTextPaint.setTextSize(CALLOUT_TEXT_SIZE * NMapResourceProvider.getScaleFactor());
    // set font type
    if (CALLOUT_TEXT_TYPEFACE != null) {
      mTextPaint.setTypeface(CALLOUT_TEXT_TYPEFACE);
    }

    mMarginX = NMapResourceProvider.toPixelFromDIP(CALLOUT_MARGIN_X);
    mPaddingX = NMapResourceProvider.toPixelFromDIP(CALLOUT_PADDING_X);
    mPaddingOffset = NMapResourceProvider.toPixelFromDIP(CALLOUT_PADDING_OFFSET);
    mPaddingY = NMapResourceProvider.toPixelFromDIP(CALLOUT_PADDING_Y);
    mMinimumWidth = NMapResourceProvider.toPixelFromDIP(CALLOUT_MIMIMUM_WIDTH);
    mTotalHeight = NMapResourceProvider.toPixelFromDIP(CALLOUT_TOTAL_HEIGHT);
    mBackgroundHeight = NMapResourceProvider.toPixelFromDIP(CALLOUT_BACKGROUND_HEIGHT);
    mItemGapY = NMapResourceProvider.toPixelFromDIP(CALLOUT_ITEM_GAP_Y);

    mTailGapX = NMapResourceProvider.toPixelFromDIP(CALLOUT_TAIL_GAP_X);
    mTailText = item.getTailText();

    mTitleOffsetY = NMapResourceProvider.toPixelFromDIP(CALLOUT_TITLE_OFFSET_Y);

    if (resourceProvider == null) {
      throw new IllegalArgumentException(
          "NMapCalloutCustomOverlay.ResourceProvider should be provided on creation of NMapCalloutCustomOverlay.");
    }

    mBackgroundDrawable = resourceProvider.getCalloutBackground(item);

    boolean hasRightAccessory = false;
    mDrawableRightButton = resourceProvider.getCalloutRightAccessory(item);
    if (mDrawableRightButton != null && mDrawableRightButton.length > 0) {
      hasRightAccessory = true;

      mRightButtonText = null;
    } else {
      mDrawableRightButton = resourceProvider.getCalloutRightButton(item);
      mRightButtonText = resourceProvider.getCalloutRightButtonText(item);
    }

    if (mDrawableRightButton != null) {
      if (hasRightAccessory) {
        mCalloutRightButtonWidth = mDrawableRightButton[0].getIntrinsicWidth();
        mCalloutRightButtonHeight = mDrawableRightButton[0].getIntrinsicHeight();
      } else {
        mCalloutRightButtonWidth = NMapResourceProvider.toPixelFromDIP(CALLOUT_RIGHT_BUTTON_WIDTH);
        mCalloutRightButtonHeight =
            NMapResourceProvider.toPixelFromDIP(CALLOUT_RIGHT_BUTTON_HEIGHT);
      }

      mRightButtonRect = new Rect();

      super.setItemCount(mCalloutButtonCount);
    } else {
      mCalloutRightButtonWidth = 0;
      mCalloutRightButtonHeight = 0;
      mRightButtonRect = null;
    }

    mTitleTruncated = null;
    mWidthTitleTruncated = 0;
  }