package com.yeshi.ec.rebate.myapplication.ui.dialog;
|
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.content.DialogInterface;
|
import android.view.Gravity;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.widget.EditText;
|
import android.widget.FrameLayout;
|
import android.widget.ImageView;
|
import android.widget.TextView;
|
|
import com.ali.auth.third.core.util.StringUtil;
|
import com.wpc.library.util.SystemCommon;
|
import com.wpc.library.util.common.DimenUtils;
|
import com.wpc.library.util.common.StringUtils;
|
import com.wpc.library.widget.ClearEditText;
|
import com.yeshi.ec.rebate.myapplication.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();
|
}
|
}
|
|
|
}
|