admin
2022-08-09 399ac289f80b7a40aa4210341db6b447cacdcf14
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
package com.tejia.lijin.app.ui.dialog;
 
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
 
import com.ali.auth.third.core.util.StringUtil;
import com.wpc.library.util.SystemCommon;
import com.wpc.library.widget.ClearEditText;
import com.tejia.lijin.app.R;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 粉丝信息标签添加
 */
 
public class TeamFansLabelAddDialog extends Dialog {
 
    public TeamFansLabelAddDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
    public TeamFansLabelAddDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
 
    public static class Builder {
        public final static int TEXT_ALIGIN_LEFT = 1;
        public final static int TEXT_ALIGIN_MIDDLE = 2;
        public final static int TEXT_ALIGIN_RIGHT = 3;
 
        private Context context;
        List<String> tagList;
        String title;
        private SetFansTagListener setFansTagListener;
 
 
        public Builder(Context context) {
            this.context = context;
        }
 
 
        public Builder setTags(List<String> tagList) {
            this.tagList = tagList;
            return this;
        }
 
        public Builder setFansTagListener(SetFansTagListener listener) {
            this.setFansTagListener = listener;
            return this;
        }
 
        public Builder setTitle(String title) {
            this.title = title;
            return this;
        }
 
 
        public TeamFansLabelAddDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final TeamFansLabelAddDialog dialog = new TeamFansLabelAddDialog(context, R.style.Dialog);
            View layout = inflater.inflate(R.layout.dialog_team_fans_label_add, null);
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
            final ClearEditText et_tag1 = layout.findViewById(R.id.et_tag1);
            final ClearEditText et_tag2 = layout.findViewById(R.id.et_tag2);
            final ClearEditText et_tag3 = layout.findViewById(R.id.et_tag3);
            if (tagList.size() > 0)
                et_tag1.setText(tagList.get(0));
 
            if (tagList.size() > 1)
                et_tag2.setText(tagList.get(1));
 
            if (tagList.size() > 2)
                et_tag3.setText(tagList.get(2));
 
            FrameLayout fl_confirm = layout.findViewById(R.id.fl_confirm);
            ImageView iv_cancle = layout.findViewById(R.id.iv_cancle);
 
            if (setFansTagListener != null) {
                fl_confirm.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        List<String> tempTagList = new ArrayList<>();
                        if (et_tag1.getText() != null && !StringUtil.isEmpty(et_tag1.getText().toString().trim())) {
                            tempTagList.add(et_tag1.getText().toString().trim());
                        }
 
                        if (et_tag2.getText() != null && !StringUtil.isEmpty(et_tag2.getText().toString().trim())) {
                            tempTagList.add(et_tag2.getText().toString().trim());
                        }
 
                        if (et_tag3.getText() != null && !StringUtil.isEmpty(et_tag3.getText().toString().trim())) {
                            tempTagList.add(et_tag3.getText().toString().trim());
                        }
                        setFansTagListener.setTag(tempTagList);
                    }
                });
            }
            iv_cancle.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (setFansTagListener != null)
                        setFansTagListener.close();
                }
            });
            dialog.setContentView(layout);
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow()
                    .getAttributes();
            params.width = (int) ((SystemCommon.getScreenWidth(context) * 3) / 4);
            params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
            dialog.getWindow().setAttributes(params);
            return dialog;
        }
 
      public  interface SetFansTagListener {
            public void setTag(List<String> tagList);
 
            public void close();
        }
    }
 
 
}