admin
2022-01-13 b9ed091e3b607af409e30aca468958cdb08641ad
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package com.ysvideo.zhibo.app.ui.dialog;
 
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.ysvideo.zhibo.app.R;
import com.ysvideo.zhibo.lib.common.util.SystemCommon;
import com.ysvideo.zhibo.lib.common.util.common.DimenUtils;
 
/**
 * 用户协议弹框
 */
public class BrowserMoreDialog extends Dialog {
 
    private static String TAG = "InputTextDialog";
 
    public BrowserMoreDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
    public BrowserMoreDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
 
    public static class Builder {
 
        private Activity context;
        private IActionListener actionListener;
 
 
        public Builder(Activity context) {
            this.context = context;
        }
 
        public Builder setActionListener(IActionListener actionListener) {
            this.actionListener = actionListener;
            return this;
        }
 
 
        public BrowserMoreDialog create() {
            final BrowserMoreDialog dialog = new BrowserMoreDialog(context, R.style.Dialog);
            dialog.setCanceledOnTouchOutside(true);
            LinearLayout linearLayout = new LinearLayout(context);
            linearLayout.setGravity(Gravity.CENTER);
            GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, new int[]{Color.parseColor("#333333"), Color.parseColor("#333333")});
            int radius = DimenUtils.dip2px(context, 16);
            gradientDrawable.setCornerRadii(new float[]{radius, radius, radius, radius, 0, 0, 0, 0});
            linearLayout.setBackground(gradientDrawable);
            linearLayout.setOrientation(LinearLayout.VERTICAL);
            TextView textView = new TextView(context);
            textView.setCompoundDrawablePadding(DimenUtils.dip2px(context, 6));
            textView.setText("刷新");
            textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_more_refresh, 0, 0, 0);
            textView.setTextSize(15.0f);
            textView.setTextColor(Color.WHITE);
            textView.setGravity(Gravity.CENTER);
            textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, DimenUtils.dip2px(context, 40)));
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (actionListener != null)
                        actionListener.onRefresh();
                }
            });
            linearLayout.addView(textView);
 
            textView = new TextView(context);
            textView.setCompoundDrawablePadding(DimenUtils.dip2px(context, 6));
            textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_more_copy, 0, 0, 0);
            textView.setText("复制链接");
            textView.setTextSize(15.0f);
            textView.setTextColor(Color.WHITE);
            textView.setGravity(Gravity.CENTER);
            textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, DimenUtils.dip2px(context, 40)));
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (actionListener != null)
                        actionListener.copyLink();
                }
            });
            linearLayout.addView(textView);
 
            textView = new TextView(context);
 
            textView.setCompoundDrawablePadding(DimenUtils.dip2px(context, 6));
            textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_more_browser, 0, 0, 0);
            textView.setText("其他浏览器打开");
            textView.setTextSize(15.0f);
            textView.setTextColor(Color.WHITE);
            textView.setGravity(Gravity.CENTER);
            textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, DimenUtils.dip2px(context, 40)));
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (actionListener != null)
                        actionListener.openInBrowser();
                }
            });
            linearLayout.addView(textView);
 
 
            dialog.setContentView(linearLayout);
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow()
                    .getAttributes();
            params.width = (int) (SystemCommon.getScreenWidth(context));
            params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
            params.gravity = Gravity.BOTTOM;
            dialog.getWindow().setAttributes(params);
            return dialog;
        }
 
 
    }
 
    public static interface IActionListener {
        public void onRefresh();
 
        public void copyLink();
 
        public void openInBrowser();
    }
 
}