summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowTipView.java
blob: abcebfec835012255020d05e5eb1f8fbeb1b7cac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.mapbox.mapboxsdk.annotations;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import com.mapbox.mapboxsdk.R;

final class InfoWindowTipView extends View {

  private Paint mPaint;
  private Path mPath;
  private int mLineWidth;

  public InfoWindowTipView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPath = new Path();
    mLineWidth = (int) context.getResources().getDimension(R.dimen.mapbox_infowindow_line_width);
    mPaint = new Paint();
    mPaint.setColor(Color.WHITE);
    mPaint.setAntiAlias(true);
    mPaint.setStrokeWidth(0.0f);
    mPaint.setStyle(Paint.Style.FILL);
  }

  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int height = getMeasuredHeight();
    int width = getMeasuredWidth();

    mPath.rewind();

    this.mPaint.setColor(Color.WHITE);
    this.mPaint.setAntiAlias(true);
    this.mPaint.setStrokeWidth(0.0f);
    this.mPaint.setStyle(Paint.Style.FILL);

    mPath.moveTo(0, 0);
    mPath.lineTo(width, 0);
    mPath.lineTo((width / 2), height);
    mPath.lineTo(0, 0);
    canvas.drawPath(mPath, this.mPaint);

    mPath.rewind();

    this.mPaint.setColor(Color.parseColor("#C2C2C2"));
    this.mPaint.setAntiAlias(true);
    this.mPaint.setStrokeWidth(mLineWidth);
    this.mPaint.setStyle(Paint.Style.STROKE);

    mPath.moveTo(0, 0);
    mPath.lineTo(width / 2, height);
    mPath.lineTo(width, 0);
    canvas.drawPath(mPath, this.mPaint);
  }
}