195 lines
7.8 KiB
Java
195 lines
7.8 KiB
Java
package com.ubt.jimu.blockly.view;
|
|
|
|
import android.app.Fragment;
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.webkit.WebChromeClient;
|
|
import android.webkit.WebSettings;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebViewClient;
|
|
import android.widget.ProgressBar;
|
|
import butterknife.ButterKnife;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.utils.NetWorkUtil;
|
|
import com.ubt.jimu.widgets.NavigationBarView;
|
|
import com.ubtech.utils.AndroidVersionCheckUtils;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class HelpFragmentCompact extends Fragment implements NavigationBarView.OnActionClickListener {
|
|
private static final String ACTIONBAR_BG_COLOR = "actionbarBackgroundColorResId";
|
|
private static final String TITLE = "title";
|
|
private static final String URL = "url";
|
|
private int actionbarBackgroundColorResId;
|
|
private OnHelpFragmentInteractionListener mListener;
|
|
protected NavigationBarView navigationBarView;
|
|
protected ProgressBar pgLoading;
|
|
private String title;
|
|
private String url;
|
|
protected WebView webView;
|
|
|
|
public class MyWebChromeClient extends WebChromeClient {
|
|
public MyWebChromeClient() {
|
|
}
|
|
|
|
@Override // android.webkit.WebChromeClient
|
|
public void onProgressChanged(WebView webView, int i) {
|
|
HelpFragmentCompact.this.pgLoading.setProgress(i);
|
|
}
|
|
}
|
|
|
|
public class MyWebViewClient extends WebViewClient {
|
|
public MyWebViewClient() {
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageFinished(WebView webView, String str) {
|
|
super.onPageFinished(webView, str);
|
|
HelpFragmentCompact.this.pgLoading.setProgress(100);
|
|
if (HelpFragmentCompact.this.actionbarBackgroundColorResId == R.color.bg_unicorn_ar_game_help) {
|
|
HelpFragmentCompact.this.navigationBarView.setLeftIvSrc(R.drawable.back_white);
|
|
HelpFragmentCompact helpFragmentCompact = HelpFragmentCompact.this;
|
|
helpFragmentCompact.navigationBarView.setBackgroundResource(helpFragmentCompact.actionbarBackgroundColorResId);
|
|
}
|
|
HelpFragmentCompact helpFragmentCompact2 = HelpFragmentCompact.this;
|
|
helpFragmentCompact2.navigationBarView.setTitle(TextUtils.isEmpty(helpFragmentCompact2.title) ? webView.getTitle() : HelpFragmentCompact.this.title);
|
|
HelpFragmentCompact.this.pgLoading.postDelayed(new Runnable() { // from class: com.ubt.jimu.blockly.view.HelpFragmentCompact.MyWebViewClient.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
HelpFragmentCompact.this.pgLoading.setVisibility(8);
|
|
}
|
|
}, 500L);
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
|
|
super.onPageStarted(webView, str, bitmap);
|
|
HelpFragmentCompact.this.pgLoading.setVisibility(0);
|
|
HelpFragmentCompact.this.pgLoading.setProgress(0);
|
|
}
|
|
}
|
|
|
|
public interface OnHelpFragmentInteractionListener {
|
|
void onHelpPageBack();
|
|
}
|
|
|
|
private void initWebView() {
|
|
this.navigationBarView.setBackgroundResource(R.color.theme_background);
|
|
if (Build.VERSION.SDK_INT >= 11) {
|
|
this.webView.removeJavascriptInterface("searchBoxJavaBridge_");
|
|
this.webView.removeJavascriptInterface("accessibility");
|
|
this.webView.removeJavascriptInterface("accessibilityTraversal");
|
|
}
|
|
this.webView.getSettings().setDisplayZoomControls(false);
|
|
this.webView.getSettings().setSupportZoom(false);
|
|
this.webView.getSettings().setUseWideViewPort(false);
|
|
this.webView.getSettings().setJavaScriptEnabled(true);
|
|
this.webView.getSettings().setLoadWithOverviewMode(true);
|
|
if (AndroidVersionCheckUtils.c()) {
|
|
this.webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
|
|
}
|
|
if (AndroidVersionCheckUtils.d()) {
|
|
this.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
|
}
|
|
this.webView.getSettings().setAllowContentAccess(true);
|
|
this.webView.getSettings().setAllowFileAccessFromFileURLs(false);
|
|
this.webView.getSettings().setAllowUniversalAccessFromFileURLs(false);
|
|
this.webView.getSettings().setDatabaseEnabled(true);
|
|
this.webView.getSettings().setDomStorageEnabled(true);
|
|
this.webView.getSettings().setAppCacheEnabled(false);
|
|
if (NetWorkUtil.b(getActivity())) {
|
|
this.webView.getSettings().setCacheMode(2);
|
|
} else {
|
|
this.webView.getSettings().setCacheMode(-1);
|
|
}
|
|
this.webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
|
this.webView.setScrollContainer(false);
|
|
this.webView.setWebViewClient(new MyWebViewClient());
|
|
this.webView.setWebChromeClient(new MyWebChromeClient());
|
|
this.webView.loadUrl(this.url);
|
|
}
|
|
|
|
public static HelpFragmentCompact newInstance(String str, String str2, int i) {
|
|
HelpFragmentCompact helpFragmentCompact = new HelpFragmentCompact();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("url", str);
|
|
bundle.putString("title", str2);
|
|
bundle.putInt(ACTIONBAR_BG_COLOR, i);
|
|
helpFragmentCompact.setArguments(bundle);
|
|
return helpFragmentCompact;
|
|
}
|
|
|
|
public boolean goBack() {
|
|
if (!this.webView.canGoBack()) {
|
|
return false;
|
|
}
|
|
this.webView.goBack();
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // android.app.Fragment
|
|
public void onAttach(Context context) {
|
|
super.onAttach(context);
|
|
if (context instanceof OnHelpFragmentInteractionListener) {
|
|
this.mListener = (OnHelpFragmentInteractionListener) context;
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
|
public void onClick(View view) {
|
|
OnHelpFragmentInteractionListener onHelpFragmentInteractionListener = this.mListener;
|
|
if (onHelpFragmentInteractionListener != null) {
|
|
onHelpFragmentInteractionListener.onHelpPageBack();
|
|
}
|
|
}
|
|
|
|
@Override // android.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
if (getArguments() != null) {
|
|
this.url = getArguments().getString("url");
|
|
this.title = getArguments().getString("title");
|
|
this.actionbarBackgroundColorResId = getArguments().getInt(ACTIONBAR_BG_COLOR);
|
|
}
|
|
}
|
|
|
|
@Override // android.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
View inflate = layoutInflater.inflate(R.layout.fragment_help, viewGroup, false);
|
|
ButterKnife.a(this, inflate);
|
|
initWebView();
|
|
if (TextUtils.isEmpty(this.title)) {
|
|
this.navigationBarView.setTitle(this.url);
|
|
} else {
|
|
this.navigationBarView.setTitle(this.title);
|
|
}
|
|
this.navigationBarView.setListener(this);
|
|
return inflate;
|
|
}
|
|
|
|
@Override // android.app.Fragment
|
|
public void onDestroy() {
|
|
this.webView.stopLoading();
|
|
this.webView.clearHistory();
|
|
this.webView.removeAllViews();
|
|
this.webView.destroy();
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override // android.app.Fragment
|
|
public void onDetach() {
|
|
super.onDetach();
|
|
this.mListener = null;
|
|
}
|
|
|
|
public void setListener(OnHelpFragmentInteractionListener onHelpFragmentInteractionListener) {
|
|
this.mListener = onHelpFragmentInteractionListener;
|
|
}
|
|
}
|