162 lines
6.0 KiB
Java
162 lines
6.0 KiB
Java
package com.ubt.jimu.base.dialog;
|
|
|
|
import android.app.Dialog;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.graphics.drawable.ColorDrawable;
|
|
import android.view.KeyEvent;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.dialog.UserExperienceDialog;
|
|
import com.ubtech.utils.DisplayUtil;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class UserExperienceDialog extends Dialog implements View.OnClickListener {
|
|
public Button btnCancel;
|
|
public Button btnOk;
|
|
public String cancel;
|
|
public String content;
|
|
private Context context;
|
|
public String ok;
|
|
private DialogInterface.OnClickListener onCancelListener;
|
|
private DialogInterface.OnClickListener onOkListener;
|
|
private TextView tvTips;
|
|
|
|
public static class Builder {
|
|
private Context context;
|
|
private DialogInterface.OnClickListener onCancelListener;
|
|
private DialogInterface.OnClickListener onOkListener;
|
|
|
|
public Builder(Context context) {
|
|
this.context = context;
|
|
}
|
|
|
|
static /* synthetic */ boolean a(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
|
|
return i == 4;
|
|
}
|
|
|
|
public UserExperienceDialog build() {
|
|
int i;
|
|
double d;
|
|
int a;
|
|
int a2;
|
|
UserExperienceDialog userExperienceDialog = new UserExperienceDialog(this.context);
|
|
userExperienceDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { // from class: com.ubt.jimu.base.dialog.b
|
|
@Override // android.content.DialogInterface.OnKeyListener
|
|
public final boolean onKey(DialogInterface dialogInterface, int i2, KeyEvent keyEvent) {
|
|
return UserExperienceDialog.Builder.a(dialogInterface, i2, keyEvent);
|
|
}
|
|
});
|
|
userExperienceDialog.context = this.context;
|
|
userExperienceDialog.onOkListener = this.onOkListener;
|
|
userExperienceDialog.onCancelListener = this.onCancelListener;
|
|
userExperienceDialog.requestWindowFeature(1);
|
|
userExperienceDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
|
|
View inflate = LayoutInflater.from(this.context).inflate(R.layout.dialog_jimu_user_experience, (ViewGroup) null, false);
|
|
userExperienceDialog.intView(inflate, this);
|
|
userExperienceDialog.setContentView(inflate);
|
|
userExperienceDialog.setCanceledOnTouchOutside(false);
|
|
Window window = userExperienceDialog.getWindow();
|
|
WindowManager.LayoutParams attributes = window.getAttributes();
|
|
window.setBackgroundDrawableResource(R.color.translucent);
|
|
window.setWindowAnimations(R.style.dialogWindowAlphaIn);
|
|
int max = Math.max(DisplayUtil.b(JimuApplication.l()), DisplayUtil.a(JimuApplication.l()));
|
|
if (JimuApplication.l().i()) {
|
|
i = (int) (max * 0.5039d);
|
|
d = 0.624d;
|
|
} else {
|
|
i = (int) (max * 0.5165d);
|
|
d = 0.6088d;
|
|
}
|
|
int i2 = (int) (i * d);
|
|
if (JimuApplication.l().i()) {
|
|
a = DisplayUtil.a(this.context, 516.0f);
|
|
a2 = DisplayUtil.a(this.context, 322.0f);
|
|
} else {
|
|
a = DisplayUtil.a(this.context, 344.55f);
|
|
a2 = DisplayUtil.a(this.context, 209.75f);
|
|
}
|
|
if (a > i || a2 > i2) {
|
|
i = a;
|
|
i2 = a2;
|
|
}
|
|
attributes.width = i;
|
|
attributes.height = i2;
|
|
attributes.gravity = 17;
|
|
window.setAttributes(attributes);
|
|
return userExperienceDialog;
|
|
}
|
|
|
|
public Builder onCancel(DialogInterface.OnClickListener onClickListener) {
|
|
this.onCancelListener = onClickListener;
|
|
return this;
|
|
}
|
|
|
|
public Builder onOk(DialogInterface.OnClickListener onClickListener) {
|
|
this.onOkListener = onClickListener;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public UserExperienceDialog(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.content.DialogInterface
|
|
public void dismiss() {
|
|
super.dismiss();
|
|
}
|
|
|
|
public void intView(View view, Builder builder) {
|
|
this.tvTips = (TextView) view.findViewById(R.id.tvTips);
|
|
this.btnCancel = (Button) view.findViewById(R.id.btnCancel);
|
|
this.btnOk = (Button) view.findViewById(R.id.btnOk);
|
|
this.btnCancel.setOnClickListener(this);
|
|
this.btnOk.setOnClickListener(this);
|
|
this.tvTips.setText("体验优化");
|
|
this.btnOk.setText(this.context.getResources().getString(R.string.gdpr_agree));
|
|
this.btnCancel.setText("暂不同意");
|
|
this.btnCancel.setBackgroundResource(R.drawable.sel_common_negative_btn);
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R.id.btnCancel) {
|
|
DialogInterface.OnClickListener onClickListener = this.onCancelListener;
|
|
if (onClickListener != null) {
|
|
onClickListener.onClick(this, 0);
|
|
return;
|
|
} else {
|
|
dismiss();
|
|
return;
|
|
}
|
|
}
|
|
if (id != R.id.btnOk) {
|
|
dismiss();
|
|
return;
|
|
}
|
|
DialogInterface.OnClickListener onClickListener2 = this.onOkListener;
|
|
if (onClickListener2 != null) {
|
|
onClickListener2.onClick(this, 0);
|
|
} else {
|
|
dismiss();
|
|
}
|
|
}
|
|
|
|
public UserExperienceDialog(Context context, int i) {
|
|
super(context, i);
|
|
}
|
|
|
|
protected UserExperienceDialog(Context context, boolean z, DialogInterface.OnCancelListener onCancelListener) {
|
|
super(context, z, onCancelListener);
|
|
}
|
|
}
|