mac
2024-06-18 73919e36e6c84a665a2c4352fa3b22d1b2e9e6bb
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
63
64
65
66
67
68
package com.hdl.photovoltaic.widget.popupview;
 
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;
 
/**
 * Author: Zoro
 * Date: 2018/11/23
 * Description: This is BasePopView
 */
 
public abstract class BasePopView extends PopupWindow {
    public View mView;
    public Context mContext;
 
    public BasePopView(Context context, int layout) {
        super(context);
        this.mContext = context;
        initPopView(layout);
    }
 
    public BasePopView(Context context, int layout, int w, int h) {
        super(context);
        this.mContext = context;
        initPopView(layout, w, h);
    }
 
 
    public void initPopView(int layout, int w, int h) {
        mView = LayoutInflater.from(mContext).inflate(layout, null, false);
        setContentView(mView);
        setWidth(w);
        setHeight(h);
        this.setFocusable(true);
        this.setTouchable(true);
        this.setOutsideTouchable(true);
        this.setBackgroundDrawable(new ColorDrawable(0));
        initContentView(mView);
    }
 
    public void initPopView(int layout) {
        initPopView(layout, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    }
 
 
//    public void showPopView(View view) {
//        showAsDropDown(view, 0, 0);
//    }
//
//    public void showPopView(View view, int x, int y) {
//        showPopView(view, x, y, Gravity.BOTTOM);
//    }
//
//    public void showPopView(View view, int x, int y, int gravity) {
//        if (this.isShowing()) {
//            this.dismiss();
//        } else {
//            this.showPopView(view, x, y, gravity);
//        }
//    }
 
    protected abstract void initContentView(View parent);
 
}