package i1; import android.content.Context; import android.content.DialogInterface; import android.content.res.Resources; import android.os.AsyncTask; import android.os.Handler; import android.os.Process; import android.util.Log; import android.view.ContextThemeWrapper; import android.view.KeyEvent; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.RelativeLayout; import android.widget.Toast; import androidx.appcompat.app.b; import busidol.mobile.tower.MainActivity; import busidol.mobile.tower.MyWebView; import busidol.mobile.tower.R; import java.io.File; /* loaded from: classes.dex */ public class k { /* renamed from: s, reason: collision with root package name */ public static String f10736s = "MainController"; /* renamed from: t, reason: collision with root package name */ public static i1.f f10737t; /* renamed from: u, reason: collision with root package name */ public static o f10738u; /* renamed from: a, reason: collision with root package name */ public MyWebView f10739a; /* renamed from: c, reason: collision with root package name */ public MainActivity f10741c; /* renamed from: e, reason: collision with root package name */ public g f10743e; /* renamed from: g, reason: collision with root package name */ public RelativeLayout f10745g; /* renamed from: k, reason: collision with root package name */ public Resources f10749k; /* renamed from: q, reason: collision with root package name */ public String f10755q = "com.skb.btv.framework"; /* renamed from: r, reason: collision with root package name */ public boolean f10756r = false; /* renamed from: f, reason: collision with root package name */ public Handler f10744f = new Handler(); /* renamed from: b, reason: collision with root package name */ public i1.e f10740b = new i1.e(this); /* renamed from: d, reason: collision with root package name */ public i1.d f10742d = new i1.d(this); /* renamed from: h, reason: collision with root package name */ public m1.b f10746h = new m1.b(this); /* renamed from: i, reason: collision with root package name */ public m1.a f10747i = new m1.a(this); /* renamed from: j, reason: collision with root package name */ public l1.a f10748j = new l1.a(this); /* renamed from: l, reason: collision with root package name */ public k1.a f10750l = new k1.a(this); /* renamed from: m, reason: collision with root package name */ public j1.a f10751m = new j1.a(this); /* renamed from: n, reason: collision with root package name */ public j f10752n = new j(this); /* renamed from: o, reason: collision with root package name */ public h f10753o = new h(this); /* renamed from: p, reason: collision with root package name */ public f1.a f10754p = new f1.a(this); class a extends p { a() { } @Override // i1.p, java.lang.Runnable public void run() { String str = (String) a("text"); o oVar = k.f10738u; if (oVar.f10765a != k.this.f10741c) { oVar.hide(); k.f10738u = null; } k.f10738u.setMessage(str); k.f10738u.show(); } } class b implements Runnable { b() { } @Override // java.lang.Runnable public void run() { o oVar = k.f10738u; if (oVar != null) { oVar.hide(); k.f10738u.dismiss(); } } } class c implements Runnable { class a extends WebViewClient { a() { } @Override // android.webkit.WebViewClient public void onPageFinished(WebView webView, String str) { super.onPageFinished(webView, str); k.this.f10739a.setWebViewClient(null); k.this.f10739a.setVisibility(0); k.this.f10745g.setVisibility(8); k.this.f10745g.clearFocus(); k.this.f10739a.requestFocus(); } @Override // android.webkit.WebViewClient public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) { } } c() { } @Override // java.lang.Runnable public void run() { if (k.this.f10740b.f10661o) { l.a(); throw null; } Log.e(k.f10736s, "loadWeb"); k kVar = k.this; kVar.f10739a.addJavascriptInterface(kVar.f10742d, "AndroidBridge"); k kVar2 = k.this; kVar2.f10739a.loadUrl(kVar2.f10740b.f10660n); k.this.f10739a.requestFocus(130); k.this.f10739a.setWebViewClient(new a()); } } class d extends p { d() { } @Override // i1.p, java.lang.Runnable public void run() { super.run(); Log.e(k.f10736s, "runnable "); String str = (String) a("title"); String str2 = (String) a("msg"); DialogInterface.OnClickListener onClickListener = (DialogInterface.OnClickListener) a("okAct"); b.a aVar = new b.a(new ContextThemeWrapper(k.this.f10741c, R.style.myDialog)); aVar.k(str); aVar.g(str2); aVar.i(R.string.str_pop_ok, onClickListener); aVar.d(false); aVar.l(); } } class e extends m { e() { } @Override // android.content.DialogInterface.OnClickListener public void onClick(DialogInterface dialogInterface, int i10) { if (((Boolean) a("isFinish")).booleanValue()) { k.this.f10742d.finish(); } else { k.this.f10756r = false; } } } class f extends AsyncTask { f() { } /* JADX INFO: Access modifiers changed from: protected */ @Override // android.os.AsyncTask /* renamed from: a, reason: merged with bridge method [inline-methods] */ public Void doInBackground(Void... voidArr) { try { k.this.i(); k.this.f10750l.f(); return null; } catch (g1.a unused) { k.this.q(true); return null; } } } public k(MainActivity mainActivity) { this.f10741c = mainActivity; this.f10749k = mainActivity.getResources(); this.f10743e = new g(mainActivity); this.f10739a = (MyWebView) mainActivity.findViewById(R.id.web_view); this.f10745g = (RelativeLayout) mainActivity.findViewById(R.id.container_logo); } public static void c(Context context) { try { d(context.getCacheDir()); Log.e("deleteCache", "deleteCache"); } catch (Exception e10) { e10.printStackTrace(); } } public static boolean d(File file) { if (file == null || !file.isDirectory()) { if (file == null || !file.isFile()) { return false; } return file.delete(); } for (String str : file.list()) { if (!d(new File(file, str))) { return false; } } return file.delete(); } public boolean a() { if (i1.e.f10642e0 == null) { return false; } for (int i10 = 0; i10 < i1.e.f10642e0.size(); i10++) { if (((String) i1.e.f10642e0.get(i10)).equals(i1.e.B)) { return true; } } return false; } public void b() { o oVar = new o(this.f10741c); f10738u = oVar; oVar.setMessage(this.f10749k.getString(R.string.str_progress_loading)); f10738u.setIndeterminate(true); f10738u.setCancelable(false); f10738u.setCanceledOnTouchOutside(false); } public String e() { return i1.e.K.getCountry(); } public String f() { return i1.e.K.getLanguage(); } public void g() { this.f10744f.post(new b()); } public void h() { b(); n(); f10737t = new i1.f(); this.f10746h.c(); this.f10747i.b(); this.f10748j.d(); this.f10739a.e(this); this.f10742d.d(); c(this.f10741c); this.f10750l.e(); this.f10752n.c(); w(); } public void i() { this.f10740b.b(); } public void j() { this.f10744f.post(new c()); } public boolean k(int i10, KeyEvent keyEvent) { if (keyEvent.getAction() == 0) { i iVar = this.f10740b.f10668v; if (i10 == iVar.f10705r || i10 == 23 || i10 == 108 || i10 == 109) { return true; } if (i10 != iVar.f10706s) { int i11 = iVar.f10707t; } else if (this.f10752n.f10714d.getVisibility() != 0) { this.f10752n.f10715e.getVisibility(); } } return false; } public void l() { m1.a aVar = this.f10747i; if (aVar != null) { aVar.e(); } MyWebView myWebView = this.f10739a; if (myWebView != null) { myWebView.g(); } f1.a aVar2 = this.f10754p; if (aVar2 != null) { aVar2.m(); } if (a()) { v(); Process.killProcess(Process.myPid()); } } public void m() { m1.a aVar = this.f10747i; if (aVar != null) { aVar.c(); } MyWebView myWebView = this.f10739a; if (myWebView != null) { myWebView.i(); } f1.a aVar2 = this.f10754p; if (aVar2 != null) { aVar2.n(); } } public void n() { i1.e.K = this.f10741c.getResources().getConfiguration().locale; } public void o(int i10, int i11, DialogInterface.OnClickListener onClickListener) { p(this.f10749k.getString(i10), this.f10749k.getString(i11), onClickListener); } public void p(String str, String str2, DialogInterface.OnClickListener onClickListener) { Log.e(f10736s, "showDialog " + str + " " + str2); MainActivity mainActivity = this.f10741c; if (mainActivity == null || mainActivity.isFinishing()) { Log.e(f10736s, "activity " + this.f10741c); return; } d dVar = new d(); dVar.b("title", str); dVar.b("msg", str2); dVar.b("okAct", onClickListener); this.f10744f.post(dVar); } public void q(boolean z10) { Log.e(f10736s, "network_init_bNetworkPop " + this.f10756r); if (this.f10756r) { return; } this.f10756r = true; e eVar = new e(); eVar.b("isFinish", Boolean.valueOf(z10)); o(R.string.str_network_error_title, R.string.str_network_error_body, eVar); } public void r() { s(R.string.str_progress_loading); } public void s(int i10) { String string = this.f10749k.getString(i10); a aVar = new a(); aVar.b("text", string); this.f10744f.post(aVar); } public void t(int i10) { Toast makeText = Toast.makeText(this.f10741c, i10, 0); makeText.setGravity(17, 0, 0); makeText.show(); } public void u(String str) { Toast makeText = Toast.makeText(this.f10741c, str, 0); makeText.setGravity(17, 0, 0); makeText.show(); } public void v() { Log.e(f10736s, "finish"); MyWebView myWebView = this.f10739a; if (myWebView != null) { myWebView.loadUrl("about:blank"); this.f10739a = null; } m1.a aVar = this.f10747i; if (aVar != null) { aVar.a(); } m1.b bVar = this.f10746h; if (bVar != null) { bVar.b(); } j1.a aVar2 = this.f10751m; if (aVar2 != null) { aVar2.h(); } f1.a aVar3 = this.f10754p; if (aVar3 != null) { aVar3.f(); } f10738u = null; this.f10756r = false; this.f10741c.finish(); } public void w() { new f().execute(new Void[0]); } }