コード例 #1
0
  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;
  }