what-the-bank/sources/com/huawei/hms/ui/AbstractDialog.java

180 lines
5.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.ui;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.UIUtil;
/* loaded from: classes2.dex */
public abstract class AbstractDialog {
private Activity a;
private AlertDialog b;
private Callback c;
/* loaded from: classes2.dex */
public interface Callback {
void onCancel(AbstractDialog abstractDialog);
void onDoWork(AbstractDialog abstractDialog);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class a implements DialogInterface.OnClickListener {
final AbstractDialog a;
a(AbstractDialog abstractDialog) {
this.a = abstractDialog;
}
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
this.a.fireDoWork();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class b implements DialogInterface.OnClickListener {
final AbstractDialog a;
b(AbstractDialog abstractDialog) {
this.a = abstractDialog;
}
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
this.a.cancel();
}
}
/* loaded from: classes2.dex */
class c implements DialogInterface.OnCancelListener {
final AbstractDialog a;
c(AbstractDialog abstractDialog) {
this.a = abstractDialog;
}
@Override // android.content.DialogInterface.OnCancelListener
public void onCancel(DialogInterface dialogInterface) {
this.a.fireCancel();
}
}
/* loaded from: classes2.dex */
class d implements DialogInterface.OnKeyListener {
final AbstractDialog a;
d(AbstractDialog abstractDialog) {
this.a = abstractDialog;
}
@Override // android.content.DialogInterface.OnKeyListener
public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
if (4 != i || keyEvent.getAction() != 1) {
return false;
}
this.a.cancel();
return true;
}
}
protected int getDialogThemeId() {
return UIUtil.getDialogThemeId(getActivity());
}
protected AlertDialog onCreateDialog(Activity activity) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), getDialogThemeId());
String onGetTitleString = onGetTitleString(activity);
if (onGetTitleString != null) {
builder.setTitle(onGetTitleString);
}
String onGetMessageString = onGetMessageString(activity);
if (onGetMessageString != null) {
builder.setMessage(onGetMessageString);
}
String onGetPositiveButtonString = onGetPositiveButtonString(activity);
if (onGetPositiveButtonString != null) {
builder.setPositiveButton(onGetPositiveButtonString, new a(this));
}
String onGetNegativeButtonString = onGetNegativeButtonString(activity);
if (onGetNegativeButtonString != null) {
builder.setNegativeButton(onGetNegativeButtonString, new b(this));
}
return builder.create();
}
protected abstract String onGetMessageString(Context context);
protected abstract String onGetNegativeButtonString(Context context);
protected abstract String onGetPositiveButtonString(Context context);
protected abstract String onGetTitleString(Context context);
public void cancel() {
AlertDialog alertDialog = this.b;
if (alertDialog != null) {
alertDialog.cancel();
}
}
public void dismiss() {
AlertDialog alertDialog = this.b;
if (alertDialog != null) {
alertDialog.dismiss();
}
}
protected void fireCancel() {
Callback callback = this.c;
if (callback != null) {
callback.onCancel(this);
}
}
protected void fireDoWork() {
Callback callback = this.c;
if (callback != null) {
callback.onDoWork(this);
}
}
public void setMessage(CharSequence charSequence) {
AlertDialog alertDialog = this.b;
if (alertDialog != null) {
alertDialog.setMessage(charSequence);
}
}
public void setTitle(CharSequence charSequence) {
AlertDialog alertDialog = this.b;
if (alertDialog != null) {
alertDialog.setTitle(charSequence);
}
}
public void show(Activity activity, Callback callback) {
this.a = activity;
this.c = callback;
if (activity != null && !activity.isFinishing()) {
AlertDialog onCreateDialog = onCreateDialog(this.a);
this.b = onCreateDialog;
onCreateDialog.setCanceledOnTouchOutside(false);
this.b.setOnCancelListener(new c(this));
this.b.setOnKeyListener(new d(this));
this.b.show();
return;
}
HMSLog.e("AbstractDialog", "In show, The activity is null or finishing.");
}
protected Activity getActivity() {
return this.a;
}
}