package com.mbridge.msdk.widget.dialog; import android.app.Dialog; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.os.Build; 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.widget.Button; import android.widget.TextView; import androidx.core.view.InputDeviceCompat; import androidx.core.view.accessibility.AccessibilityEventCompat; import com.mbridge.msdk.c.g; import com.mbridge.msdk.c.h; import com.mbridge.msdk.foundation.controller.c; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.foundation.tools.an; import com.mbridge.msdk.foundation.tools.x; import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode; import java.util.Locale; import org.apache.http.protocol.HTTP; /* loaded from: classes4.dex */ public class MBAlertDialog extends Dialog { private Button a; private Button b; private TextView c; private a d; private TextView e; public void clear() { if (this.d != null) { this.d = null; } } public a getListener() { return this.d; } public void makeDownloadAlert(String str) { } public void makeInsAlert(String str) { } public MBAlertDialog(Context context, final a aVar) { super(context); getWindow().setBackgroundDrawable(new ColorDrawable(0)); requestWindowFeature(1); View inflate = LayoutInflater.from(context).inflate(x.a(context, "mbridge_cm_alertview", TtmlNode.TAG_LAYOUT), (ViewGroup) null); this.d = aVar; if (inflate != null) { setContentView(inflate); try { this.e = (TextView) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_titleview", "id")); } catch (Exception e) { af.a("MBAlertDialog", e.getMessage()); } try { this.c = (TextView) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_contentview", "id")); this.b = (Button) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_confirm_button", "id")); this.a = (Button) inflate.findViewById(x.a(context, "mbridge_video_common_alertview_cancel_button", "id")); } catch (Exception e2) { af.a("MBAlertDialog", e2.getMessage()); } } Button button = this.a; if (button != null) { button.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.widget.dialog.MBAlertDialog.1 @Override // android.view.View.OnClickListener public final void onClick(View view) { a aVar2 = aVar; if (aVar2 != null) { aVar2.a(); } MBAlertDialog.this.cancel(); MBAlertDialog.this.clear(); } }); } Button button2 = this.b; if (button2 != null) { button2.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.widget.dialog.MBAlertDialog.2 @Override // android.view.View.OnClickListener public final void onClick(View view) { a aVar2 = aVar; if (aVar2 != null) { aVar2.b(); } MBAlertDialog.this.cancel(); MBAlertDialog.this.clear(); } }); } setCanceledOnTouchOutside(false); setCancelable(false); } public void makeIVAlertView(int i, String str) { try { String obj = an.a(getContext(), "MBridge_ConfirmTitle" + str, "").toString(); String obj2 = an.a(getContext(), "MBridge_ConfirmContent" + str, "").toString(); String obj3 = an.a(getContext(), "MBridge_CancelText" + str, "").toString(); String obj4 = an.a(getContext(), "MBridge_ConfirmText" + str, "").toString(); if (!TextUtils.isEmpty(obj) || !TextUtils.isEmpty(obj2) || !TextUtils.isEmpty(obj3) || !TextUtils.isEmpty(obj4)) { a(obj, obj2, obj3, obj4); } else { String language = Locale.getDefault().getLanguage(); if (!TextUtils.isEmpty(language) && language.equals("zh")) { setTitle(i == com.mbridge.msdk.foundation.same.a.H ? "确认关闭?" : "提示"); setContent(i == com.mbridge.msdk.foundation.same.a.H ? "如果你选择继续,结束后将会获得奖励。确认关闭吗?" : "如果你选择继续,结束后将会获得奖励。是否继续?"); setConfirmText(i == com.mbridge.msdk.foundation.same.a.H ? "确认关闭" : "取消"); setCancelText("继续"); } else { setTitle(i == com.mbridge.msdk.foundation.same.a.H ? "Confirm" : "Tips"); setContent(i == com.mbridge.msdk.foundation.same.a.H ? "If you choose to continue, you will receive a reward after the end. Confirm closed?" : "If you choose to continue, you will receive a reward after the end. Whether to continue?"); setConfirmText(i == com.mbridge.msdk.foundation.same.a.H ? HTTP.CONN_CLOSE : "Cancel"); setCancelText("Continue"); } } } catch (Exception e) { af.a("MBAlertDialog", e.getMessage()); } } private void a(String str, String str2, String str3, String str4) { setTitle(str); setContent(str2); setConfirmText(str3); setCancelText(str4); } public void setTitle(String str) { TextView textView = this.e; if (textView != null) { textView.setText(str); } } public void setContent(String str) { TextView textView = this.c; if (textView != null) { textView.setText(str); } } public void setConfirmText(String str) { Button button = this.b; if (button != null) { button.setText(str); } } public void setCancelText(String str) { Button button = this.a; if (button != null) { button.setText(str); } } public void makePlayableAlertView() { g b = h.a().b(c.m().k()); if (b != null) { a(b.z(), b.x(), b.y(), b.v()); return; } String language = Locale.getDefault().getLanguage(); if (!TextUtils.isEmpty(language) && language.equals("zh")) { setTitle("确认关闭?"); setContent("关闭后您将不会获得任何奖励噢~ "); setConfirmText("确认关闭"); setCancelText("继续试玩"); return; } setTitle("Confirm to close? "); setContent("You will not be rewarded after closing the window"); setConfirmText("Close it"); setCancelText("Continue"); } public void makeRVAlertView(String str) { try { String obj = an.a(getContext(), "MBridge_ConfirmTitle" + str, "").toString(); String obj2 = an.a(getContext(), "MBridge_ConfirmContent" + str, "").toString(); String obj3 = an.a(getContext(), "MBridge_CancelText" + str, "").toString(); String obj4 = an.a(getContext(), "MBridge_ConfirmText" + str, "").toString(); g b = h.a().b(c.m().k()); if (TextUtils.isEmpty(obj) && TextUtils.isEmpty(obj2) && TextUtils.isEmpty(obj3) && TextUtils.isEmpty(obj4)) { if (b != null) { a(b.z(), b.x(), b.y(), b.w()); return; } String language = Locale.getDefault().getLanguage(); if (!TextUtils.isEmpty(language) && language.equals("zh")) { setTitle("确认关闭?"); setContent("关闭后您将不会获得任何奖励噢~ "); setConfirmText("确认关闭"); setCancelText("继续观看"); return; } setTitle("Confirm to close? "); setContent("You will not be rewarded after closing the window"); setConfirmText("Close it"); setCancelText("Continue"); return; } String language2 = Locale.getDefault().getLanguage(); if (TextUtils.isEmpty(obj)) { if (b != null) { obj = b.z(); } else if (!TextUtils.isEmpty(language2) && language2.equals("zh")) { setTitle("确认关闭?"); } else { setTitle("Confirm to close? "); } } if (TextUtils.isEmpty(obj2)) { if (b != null) { obj2 = b.x(); } else if (!TextUtils.isEmpty(language2) && language2.equals("zh")) { setContent("关闭后您将不会获得任何奖励噢~ "); } else { setContent("You will not be rewarded after closing the window"); } } if (TextUtils.isEmpty(obj4)) { if (b != null) { obj4 = b.y(); } else if (!TextUtils.isEmpty(language2) && language2.equals("zh")) { setConfirmText("确认关闭"); } else { setConfirmText("Close it"); } } if (TextUtils.isEmpty(obj3)) { if (b != null) { obj3 = b.w(); } else if (!TextUtils.isEmpty(language2) && language2.equals("zh")) { setCancelText("继续观看"); } else { setCancelText("Continue"); } } a(obj, obj2, obj4, obj3); } catch (Exception e) { af.a("MBAlertDialog", e.getMessage()); } } public void onlyShow() { super.show(); } @Override // android.app.Dialog public void show() { super.show(); try { getWindow().setFlags(8, 8); super.show(); hideNavigationBar(getWindow()); getWindow().clearFlags(8); } catch (Exception e) { af.b("MBAlertDialog", e.getMessage()); super.show(); } } public void hideNavigationBar(Window window) { if (window != null) { window.setFlags(1024, 1024); int i = Build.VERSION.SDK_INT; window.addFlags(AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL); window.getDecorView().setSystemUiVisibility(InputDeviceCompat.SOURCE_TOUCHSCREEN); if (i >= 28) { WindowManager.LayoutParams attributes = window.getAttributes(); attributes.layoutInDisplayCutoutMode = 1; window.setAttributes(attributes); } window.setBackgroundDrawable(new ColorDrawable(0)); window.setLayout(-1, -1); window.setGravity(17); } } }