public class NotRegisterDialog {
private Context context;
private Dialog dialog;
private Display display;
private ImageView goIntent,neglect,close,logoDialog;
private TextView content;
public NotRegisterDialog(Context context) {
this.context = context;
WindowManager windowManager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
display = windowManager.getDefaultDisplay();
}
public NotRegisterDialog builder() {
// 获取Dialog布局
View view = LayoutInflater.from(context).inflate(
R.layout.dialog_not_login, null);
// 获取自定义Dialog布局中的控件
RelativeLayout bgNotLogin = (RelativeLayout) view.findViewById(R.id.bgNotLogin);
goIntent = view.findViewById(R.id.goIntent);
neglect = view.findViewById(R.id.neglect);
close = view.findViewById(R.id.close);
content = view.findViewById(R.id.content);
logoDialog = view.findViewById(R.id.logoDialog);
// 定义Dialog布局和参数
dialog = new Dialog(context, R.style.AlertDialogStyle);
dialog.setContentView(view);
// 调整dialog背景大小
bgNotLogin.setLayoutParams(new FrameLayout.LayoutParams(
DensityUtil.dip2px(context, 268),
DensityUtil.dip2px(context, 296)
));
return this;
}
public NotRegisterDialog setContent(String str){
content.setText(str);
return this;
}
public NotRegisterDialog setGoIntentImg(@DrawableRes int str){
goIntent.setImageResource(str);
return this;
}
public NotRegisterDialog setlogoDialogImg(@DrawableRes int str){
logoDialog.setImageResource(str);
return this;
}
public NotRegisterDialog setCancelable(boolean cancel) {
dialog.setCancelable(cancel);
dialog.setCanceledOnTouchOutside(cancel);
return this;
}
public NotRegisterDialog setGoRegister(View.OnClickListener listener){
if (goIntent!=null){
goIntent.setOnClickListener(view ->{
listener.onClick(view);
dialog.dismiss();
});
}
return this;
}
public NotRegisterDialog setCancle(View.OnClickListener listener){
if (neglect!=null){
neglect.setOnClickListener(view ->{
listener.onClick(view);
dialog.dismiss();
});
}
return this;
}
public void show() {
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
}
|
||
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
|
||
| 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 |
|
|