summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubblePopupHelper.java
blob: 055bfe5368976c31030b4714a213a20cf3bbd561 (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
package com.mapbox.mapboxsdk.annotations;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.mapbox.mapboxsdk.R;

@Deprecated
class BubblePopupHelper {

  @NonNull
  static PopupWindow create(@NonNull Context context, @NonNull BubbleLayout bubbleLayout) {
    PopupWindow popupWindow = new PopupWindow(context);

    popupWindow.setContentView(bubbleLayout);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
    // change background color to transparent
    Drawable drawable;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      drawable = context.getDrawable(R.drawable.mapbox_popup_window_transparent);
    } else {
      drawable = context.getResources().getDrawable(R.drawable.mapbox_popup_window_transparent);
    }
    popupWindow.setBackgroundDrawable(drawable);

    return popupWindow;
  }
}