jimu-decompiled/sources/com/ubtech/view/dialog/SimpleDialog.java
2025-05-13 19:24:51 +02:00

284 lines
8.6 KiB
Java

package com.ubtech.view.dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.ColorDrawable;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.ubtech.R$color;
import com.ubtech.R$dimen;
import com.ubtech.R$id;
import com.ubtech.R$layout;
import com.ubtech.utils.DisplayUtil;
import com.ubtech.view.widget.UButton;
/* loaded from: classes2.dex */
public class SimpleDialog extends BaseDialog implements View.OnClickListener {
public CharSequence b;
public String c;
public String d;
public boolean e;
public int f;
public int g;
public int h;
public DialogInterface.OnClickListener i;
public DialogInterface.OnClickListener j;
public View.OnClickListener k;
private TextView l;
private TextView m;
private ImageView n;
public UButton o;
public UButton p;
public UButton q;
public UButton r;
public static class Builder {
protected Context a;
protected String b;
protected CharSequence c;
protected String d;
protected String e;
protected String g;
protected DialogInterface.OnClickListener k;
protected DialogInterface.OnClickListener l;
protected View.OnClickListener m;
protected int o;
protected int f = 0;
protected boolean h = true;
protected boolean i = true;
protected int j = 17;
protected boolean n = false;
protected int p = -1;
protected int q = -1;
public Builder(Context context) {
this.o = 0;
this.a = context;
this.o = context.getResources().getColor(R$color.comm_bg_596F80);
}
public SimpleDialog a() {
SimpleDialog simpleDialog = new SimpleDialog(this.a);
simpleDialog.requestWindowFeature(1);
simpleDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
simpleDialog.e = this.n;
simpleDialog.b = this.c;
simpleDialog.d = this.e;
simpleDialog.c = this.d;
simpleDialog.j = this.l;
simpleDialog.i = this.k;
simpleDialog.k = this.m;
simpleDialog.f = this.o;
simpleDialog.h = this.q;
simpleDialog.g = this.p;
View inflate = LayoutInflater.from(this.a).inflate(R$layout.comm_dialog_simple, (ViewGroup) null, false);
simpleDialog.a(inflate, this);
simpleDialog.setContentView(inflate);
simpleDialog.setCanceledOnTouchOutside(this.h);
simpleDialog.setCancelable(this.i);
Window window = simpleDialog.getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
window.setBackgroundDrawableResource(R$color.comm_transparent);
int a = DisplayUtil.a(this.a, R$dimen.theme_dialog_window_width);
int a2 = DisplayUtil.a(this.a, R$dimen.theme_dialog_window_height);
attributes.width = a;
attributes.height = a2;
attributes.gravity = 17;
window.setAttributes(attributes);
return simpleDialog;
}
public Builder b(int i) {
this.c = this.a.getString(i);
return this;
}
public Builder c(int i) {
this.f = i;
return this;
}
public Builder d(int i) {
this.e = this.a.getString(i);
return this;
}
public Builder b(String str) {
this.e = str;
return this;
}
public Builder b(boolean z) {
this.i = z;
return this;
}
public Builder b(DialogInterface.OnClickListener onClickListener) {
this.l = onClickListener;
return this;
}
public Builder a(CharSequence charSequence) {
this.c = charSequence;
return this;
}
public Builder a(String str) {
this.d = str;
return this;
}
public Builder a(String str, boolean z) {
this.d = str;
this.n = z;
return this;
}
public Builder a(int i) {
this.d = this.a.getString(i);
return this;
}
public Builder a(int i, boolean z) {
this.d = this.a.getString(i);
this.n = z;
return this;
}
public Builder a(boolean z) {
this.h = z;
return this;
}
public Builder a(String str, int i, int i2) {
this.g = str;
this.p = i;
this.q = i2;
return this;
}
public Builder a(DialogInterface.OnClickListener onClickListener) {
this.k = onClickListener;
return this;
}
}
public SimpleDialog(Context context) {
super(context);
this.e = false;
this.f = 0;
this.g = -1;
this.h = -1;
}
public void a(View view, Builder builder) {
this.l = (TextView) view.findViewById(R$id.tvDialogTitle);
this.m = (TextView) view.findViewById(R$id.tvTips);
this.n = (ImageView) view.findViewById(R$id.imgLogo);
this.p = (UButton) view.findViewById(R$id.btn_gray_cancel);
this.q = (UButton) view.findViewById(R$id.btn_blue_cancel);
this.q.setOnClickListener(this);
this.o = (UButton) view.findViewById(R$id.btn_ok);
this.r = (UButton) view.findViewById(R$id.btn_gray_cancel);
this.r.setOnClickListener(this);
this.o.setOnClickListener(this);
if (!TextUtils.isEmpty(this.b)) {
this.m.setText(this.b);
this.m.setMovementMethod(ScrollingMovementMethod.getInstance());
}
this.m.setOnClickListener(this);
if (this.j == null) {
this.o.setVisibility(8);
}
if (!TextUtils.isEmpty(this.d)) {
this.o.setText(this.d);
}
if (TextUtils.isEmpty(builder.b)) {
this.l.setVisibility(8);
} else {
this.l.setVisibility(0);
this.l.setText(builder.b);
}
if (TextUtils.isEmpty(builder.g)) {
int i = builder.f;
if (i != 0) {
this.n.setImageResource(i);
this.n.setVisibility(0);
} else {
this.n.setVisibility(8);
}
} else {
Glide.e(getContext()).a(builder.g).a(this.n);
this.n.setVisibility(0);
if (this.h > 0 && this.g > 0) {
ViewGroup.LayoutParams layoutParams = this.n.getLayoutParams();
layoutParams.height = this.h;
layoutParams.width = this.g;
this.n.setLayoutParams(layoutParams);
}
}
int i2 = builder.j;
if (17 != i2) {
this.m.setGravity(i2);
}
if (this.e) {
this.q.setVisibility(8);
this.p.setVisibility(0);
this.r = this.p;
} else {
this.q.setVisibility(0);
this.p.setVisibility(8);
this.r = this.q;
}
if (this.i == null) {
this.p.setVisibility(8);
this.q.setVisibility(8);
}
if (!TextUtils.isEmpty(this.c)) {
this.r.setText(this.c);
}
this.m.setTextColor(this.f);
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
int id = view.getId();
if (id == R$id.btn_gray_cancel || id == R$id.btn_blue_cancel) {
DialogInterface.OnClickListener onClickListener = this.i;
if (onClickListener != null) {
onClickListener.onClick(this, 0);
return;
} else {
dismiss();
return;
}
}
if (id == R$id.btn_ok) {
DialogInterface.OnClickListener onClickListener2 = this.j;
if (onClickListener2 != null) {
onClickListener2.onClick(this, 0);
return;
} else {
dismiss();
return;
}
}
if (id != R$id.tvTips) {
dismiss();
return;
}
View.OnClickListener onClickListener3 = this.k;
if (onClickListener3 != null) {
onClickListener3.onClick(this.m);
}
}
}