jimu-decompiled/sources/com/ubt/jimu/widgets/JAlertDialog.java
2025-05-13 19:24:51 +02:00

152 lines
4.5 KiB
Java

package com.ubt.jimu.widgets;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatDialog;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.R;
import com.ubtech.utils.DisplayUtil;
/* loaded from: classes2.dex */
public class JAlertDialog extends AppCompatDialog {
private String c;
private boolean d;
private int e;
private TextView f;
private ImageView g;
public static class Builder {
private Context a;
private JAlertDialog b;
public Builder(Context context) {
this.a = context;
this.b = new JAlertDialog(context);
}
public Builder a(String str) {
this.b.c = str;
return this;
}
public Builder b(int i) {
this.b.c = this.a.getString(i);
return this;
}
public Builder a(int i) {
this.b.e = i;
return this;
}
public Builder b(boolean z) {
this.b.setCancelable(z);
return this;
}
public Builder a(boolean z) {
this.b.d = z;
return this;
}
public JAlertDialog a() {
View inflate = LayoutInflater.from(this.a).inflate(R.layout.alert_dialog, (ViewGroup) null, false);
ImageView imageView = (ImageView) inflate.findViewById(R.id.imageView);
if (this.b.e != 0) {
imageView.setImageResource(this.b.e);
}
TextView textView = (TextView) inflate.findViewById(R.id.textView);
if (!TextUtils.isEmpty(this.b.c)) {
textView.setText(this.b.c);
} else {
textView.setVisibility(8);
}
if (this.b.d) {
JAlertDialog.b(imageView);
}
this.b.f = textView;
this.b.g = imageView;
this.b.setContentView(inflate);
Window window = this.b.getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
window.setBackgroundDrawableResource(R.color.translucent);
window.setWindowAnimations(R.style.dialogWindowAlphaIn);
int b = DisplayUtil.b(this.a);
int a = DisplayUtil.a(this.a);
boolean i = JimuApplication.l().i();
int max = Math.max(b, a);
int min = Math.min(b, a);
attributes.width = i ? max / 5 : (max * 11) / 50;
attributes.height = i ? min / 4 : (min * 17) / 50;
attributes.gravity = 17;
window.setAttributes(attributes);
return this.b;
}
}
public JAlertDialog(Context context) {
this(context, R.style.common_alert_dialog);
}
@Override // android.app.Dialog, android.content.DialogInterface
public void dismiss() {
ImageView imageView = this.g;
if (imageView != null) {
imageView.post(new Runnable() { // from class: com.ubt.jimu.widgets.JAlertDialog.1
@Override // java.lang.Runnable
public void run() {
JAlertDialog.this.g.clearAnimation();
}
});
}
super.dismiss();
}
public JAlertDialog(Context context, int i) {
super(context, i);
setCanceledOnTouchOutside(false);
}
public void b(int i) {
ImageView imageView = this.g;
if (imageView != null) {
imageView.setImageResource(i);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static void b(View view) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "rotation", 0.0f, 180.0f, 360.0f);
ofFloat.setRepeatCount(-1);
ofFloat.setRepeatMode(1);
ofFloat.setDuration(1200L);
ofFloat.setInterpolator(new LinearInterpolator());
ofFloat.start();
}
public void a(String str) {
TextView textView = this.f;
if (textView != null) {
textView.setText(str);
}
}
public void a(boolean z) {
ImageView imageView = this.g;
if (imageView == null || !z) {
return;
}
this.d = true;
b(imageView);
}
}