package com.slzhibo.library.ui.view.dialog; import android.annotation.TargetApi; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.TextView; import com.slzhibo.library.R; import com.slzhibo.library.ui.view.dialog.base.BaseBottomDialogFragment; import com.slzhibo.library.ui.view.widget.Html5WebView; import com.tencent.smtt.export.external.interfaces.WebResourceError; import com.tencent.smtt.export.external.interfaces.WebResourceRequest; import com.tencent.smtt.export.external.interfaces.WebResourceResponse; import com.tencent.smtt.sdk.WebView; public class WebViewDialog extends BaseBottomDialogFragment { private ProgressBar K0; private FrameLayout L0; private FrameLayout M0; private Html5WebView N0; private String O0; private String P0; private volatile boolean Q0 = false; /* access modifiers changed from: package-private */ public class a implements DialogInterface.OnKeyListener { a() { } public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) { if (keyEvent.getAction() != 0 || i != 4 || WebViewDialog.this.N0 == null || !WebViewDialog.this.N0.canGoBack()) { return false; } WebViewDialog.this.N0.goBack(); return true; } } /* access modifiers changed from: private */ public class b extends Html5WebView.a { private b() { } @Override // com.tencent.smtt.sdk.WebChromeClient public void onProgressChanged(WebView webView, int i) { super.onProgressChanged(webView, i); WebViewDialog.this.K0.setProgress(i); } /* synthetic */ b(WebViewDialog webViewDialog, a aVar) { this(); } } private void i() { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1); this.N0 = new Html5WebView(this.t.getApplicationContext()); this.N0.setLayoutParams(layoutParams); this.L0.addView(this.N0); this.N0.setWebChromeClient(new b(this, null)); this.N0.setWebViewClient(new c()); this.N0.setDownloadListener(new n3(this)); Html5WebView html5WebView = this.N0; if (html5WebView != null) { html5WebView.loadUrl(this.O0); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void j() { this.Q0 = true; b(3); } @Override // com.slzhibo.library.ui.view.dialog.base.BaseRxDialogFragment public float b() { return 0.0f; } @Override // com.slzhibo.library.ui.view.dialog.base.BaseBottomDialogFragment public double g() { return this.J0; } @Override // com.slzhibo.library.ui.view.dialog.base.BaseBottomDialogFragment public int h() { return R.layout.fq_dialog_bottom_webview; } @Override // androidx.fragment.app.Fragment, com.slzhibo.library.utils.rxlifecycle2.components.support.RxDialogFragment public void onDestroy() { Html5WebView html5WebView = this.N0; if (html5WebView != null) { html5WebView.j(); this.N0 = null; } super.onDestroy(); } @Override // androidx.fragment.app.Fragment, com.slzhibo.library.utils.rxlifecycle2.components.support.RxDialogFragment public void onPause() { super.onPause(); Html5WebView html5WebView = this.N0; if (html5WebView != null) { html5WebView.onPause(); } } @Override // androidx.fragment.app.Fragment, com.slzhibo.library.utils.rxlifecycle2.components.support.RxDialogFragment public void onResume() { super.onResume(); Html5WebView html5WebView = this.N0; if (html5WebView != null) { html5WebView.onResume(); } } public static WebViewDialog b(String str, String str2) { Bundle bundle = new Bundle(); WebViewDialog webViewDialog = new WebViewDialog(); bundle.putString("title", str); bundle.putString("url", str2); webViewDialog.setArguments(bundle); return webViewDialog; } /* access modifiers changed from: private */ public /* synthetic */ void d(View view) { Html5WebView html5WebView = this.N0; if (html5WebView != null) { html5WebView.loadUrl(this.O0); } } @Override // com.slzhibo.library.ui.view.dialog.base.BaseBottomDialogFragment public void c(View view) { TextView textView = (TextView) view.findViewById(R.id.tv_title); this.K0 = (ProgressBar) view.findViewById(R.id.pb); this.L0 = (FrameLayout) view.findViewById(R.id.fl_content_view); this.M0 = (FrameLayout) view.findViewById(R.id.fl_retry_view); textView.setText(TextUtils.isEmpty(this.P0) ? "" : this.P0); i(); } /* access modifiers changed from: package-private */ public class c extends Html5WebView.b { c() { } @Override // com.tencent.smtt.sdk.WebViewClient public void onPageFinished(WebView webView, String str) { super.onPageFinished(webView, str); if (WebViewDialog.this.Q0) { WebViewDialog.this.j(); return; } WebViewDialog.this.Q0 = false; WebViewDialog.this.b((WebViewDialog) 2); } @Override // com.tencent.smtt.sdk.WebViewClient public void onPageStarted(WebView webView, String str, Bitmap bitmap) { super.onPageStarted(webView, str, bitmap); WebViewDialog.this.Q0 = false; WebViewDialog.this.b((WebViewDialog) 1); } @Override // com.tencent.smtt.sdk.WebViewClient public void onReceivedError(WebView webView, int i, String str, String str2) { super.onReceivedError(webView, i, str, str2); if (Build.VERSION.SDK_INT < 23) { WebViewDialog.this.j(); } } @Override // com.tencent.smtt.sdk.WebViewClient public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) { super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse); if (webResourceRequest.isForMainFrame()) { WebViewDialog.this.j(); } } @Override // com.slzhibo.library.ui.view.widget.Html5WebView.b, com.tencent.smtt.sdk.WebViewClient public boolean shouldOverrideUrlLoading(WebView webView, String str) { if (str.startsWith("pt://")) { try { WebViewDialog.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str))); } catch (Exception unused) { webView.loadUrl("https://www.potato.im/p/androids"); } return false; } else if (!str.startsWith("http") || !str.startsWith(e.a.b.c.b.a)) { return true; } else { if (Build.VERSION.SDK_INT >= 26) { return false; } webView.loadUrl(str); return true; } } @Override // com.tencent.smtt.sdk.WebViewClient @TargetApi(23) public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) { super.onReceivedError(webView, webResourceRequest, webResourceError); if (webResourceRequest.isForMainFrame()) { WebViewDialog.this.j(); } } } @Override // com.slzhibo.library.ui.view.dialog.base.BaseRxDialogFragment public void a(Bundle bundle) { super.a(bundle); this.P0 = bundle.getString("title"); this.O0 = bundle.getString("url"); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void b(int i) { int i2 = 0; this.K0.setVisibility(i == 1 ? 0 : 8); this.M0.setVisibility(i == 3 ? 0 : 4); Html5WebView html5WebView = this.N0; if (html5WebView != null) { if (i != 2) { i2 = 4; } html5WebView.setVisibility(i2); } } /* access modifiers changed from: protected */ @Override // com.slzhibo.library.ui.view.dialog.base.BaseBottomDialogFragment public void a(View view) { super.a(view); view.findViewById(R.id.tv_btn_reload).setOnClickListener(new o3(this)); Dialog dialog = this.H0; if (dialog != null) { dialog.setOnKeyListener(new a()); } } /* access modifiers changed from: private */ public /* synthetic */ void a(String str, String str2, String str3, String str4, long j) { try { startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str))); } catch (Exception e2) { e2.printStackTrace(); } } }