必贏亚洲 v2.5.14版本的 MD5 值为:1cbf75cf2fbc8fc1c58914009bfdab8f

以下内容为反编译后的 WebViewActivity.java 源代码,内容仅作参考


package com.weinet.cashap.pluslibrary.activitys;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.google.gson.GsonBuilder;
import com.weinet.cashap.pluslibrary.R;
import com.weinet.cashap.pluslibrary.activitys.WebViewActivity;
import com.weinet.cashap.pluslibrary.cache.CacheBuilder;
import com.weinet.cashap.pluslibrary.cache.WebViewCacheInterceptor;
import com.weinet.cashap.pluslibrary.cache.config.CacheType;
import com.weinet.cashap.pluslibrary.components.FullscreenHolder;
import com.weinet.cashap.pluslibrary.components.IWebPageView;
import com.weinet.cashap.pluslibrary.components.InterceptingWebViewClient;
import com.weinet.cashap.pluslibrary.components.MyWebChromeClient;
import com.weinet.cashap.pluslibrary.dialogs.Dialog_mandatory;
import com.weinet.cashap.pluslibrary.handlers.AppInfoErrorHandler;
import com.weinet.cashap.pluslibrary.handlers.AppInfoSuccessHandler;
import com.weinet.cashap.pluslibrary.handlers.CheckUrlStatusThread;
import com.weinet.cashap.pluslibrary.handlers.CheckWebUrlStatusHandler;
import com.weinet.cashap.pluslibrary.handlers.DomainInfoLoadThread_OKClient;
import com.weinet.cashap.pluslibrary.handlers.UpdateDialogCallbackHandler;
import com.weinet.cashap.pluslibrary.handlers.WebViewActivityInterface;
import com.weinet.cashap.pluslibrary.models.AppInfoModel;
import com.weinet.cashap.pluslibrary.models.AppSettingModel;
import com.weinet.cashap.pluslibrary.models.AppVerModel;
import com.weinet.cashap.pluslibrary.utils.BooleanTypeAdapter;
import com.weinet.cashap.pluslibrary.utils.CheckNetwork;
import com.weinet.cashap.pluslibrary.utils.LanguageManager;
import com.weinet.cashap.pluslibrary.utils.OkHttpClientHelper;
import com.weinet.cashap.pluslibrary.utils.OkHttpDataHelper;
import com.weinet.cashap.pluslibrary.utils.OkHttpIPHelper;
import com.weinet.cashap.pluslibrary.utils.Tools;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import okhttp3.Response;
import org.json.JSONException;
import org.json.JSONObject;
public class WebViewActivity extends AppCompatActivity implements IWebPageView, WebViewActivityInterface {
    private static final String TAG = "AppInfo";
    public static String defaultScreenOrientation = "FULL_SENSOR";
    public static Boolean isFirstSuccess = false;
    private String __checkUrlValue;
    private String __getAppInfoUrl;
    private Context context;
    private Handler detectionMD5Handler;
    private Iterator<String> domainUrlIterator;
    private List<String> domainUrlList;
    private Iterator<String> ipUrlList;
    ProgressBar mProgressBar;
    private MyWebChromeClient mWebChromeClient;
    private Iterator<String> serverUrlList;
    public Dialog_mandatory updateDialog;
    FrameLayout videoFullView;
    WebView webView;
    private final AppInfoErrorHandler appInfoErrorHandler = new AppInfoErrorHandler(Looper.getMainLooper(), this);
    private final AppInfoSuccessHandler appInfoSuccessHandler = new AppInfoSuccessHandler(Looper.getMainLooper(), this);
    private final CheckWebUrlStatusHandler checkWebUrlStatusHandler = new CheckWebUrlStatusHandler(Looper.getMainLooper(), this);
    private final UpdateDialogCallbackHandler updateDialogCallbackHandler = new UpdateDialogCallbackHandler(this);
    private String urlCkeckResult = "";
    private boolean isLoadUrlTimeOut = true;
    private int __getAppInfoCounter = 4;
    private int __checkUrlStatusCount = 0;
    private int __checkUrlCounter = 0;
    private boolean isReconnection = false;
    private long timeoutCheck = 3000;

    @Override
    public void addImageClickListener() {
    }

    @Override
    public void saveLocalDomainInfo(AppInfoModel appInfoModel) {
        try {
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.registerTypeAdapter(Boolean.TYPE, new BooleanTypeAdapter());
            Tools.setAppInfo(this.context, gsonBuilder.create().toJson(appInfoModel));
            AppSettingModel.getInstance().setNewAppVerModel(appInfoModel.app);
            this.domainUrlList = appInfoModel.sitedomain;
            this.domainUrlIterator = appInfoModel.sitedomain.iterator();
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_web_view);
        AppSettingModel appSettingModel = AppSettingModel.getInstance();
        LanguageManager.getInstance().setLanguage(this, appSettingModel.getCurrentLanguageCode());
        this.mProgressBar = (ProgressBar) findViewById(R.id.pb_progress);
        this.webView = (WebView) findViewById(R.id.webview_detail);
        Log.i(TAG, "isWifiProxy " + Tools.isWifiProxy(this));
        this.context = this;
        if (Build.VERSION.SDK_INT < 21) {
            showDomainInfoErrDialog(getString(R.string.tips_title_default), getString(R.string.tips_low_system_ver), this.context);
            return;
        }
        try {
            appSettingModel.setAppVersion(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
            ((TextView) findViewById(R.id.text_AppVersion)).setText(String.format(getString(R.string.version_label), appSettingModel.getAppVersion()));
        } catch (Exception e) {
            Log.i(TAG, "set AppSetting.AppVersion Exception " + e.getMessage());
        }
        initWebView();
        appSettingModel.setUserAgent(this.webView.getSettings().getUserAgentString());
        Log.i(TAG, "webview useragent = " + appSettingModel.getUserAgent());
        if (!CheckNetwork.isNetworkConnected(this)) {
            try {
                WebView webView = this.webView;
                webView.loadUrl(appSettingModel.getNetWorkErrorUrl() + "?name=" + URLEncoder.encode(AppSettingModel.getInstance().getAPPName(), "utf-8") + "&view=webview");
                return;
            } catch (UnsupportedEncodingException e2) {
                throw new RuntimeException(e2);
            }
        }
        ((TextView) findViewById(R.id.checkStatusDesc)).setText(getString(R.string.net_status_init));
        AppInfoModel localAppInfoJson = Tools.getLocalAppInfoJson(this);
        AppSettingModel.getInstance().setAppInfoModel(localAppInfoJson);
        AppSettingModel.getInstance().setInterceptList(localAppInfoJson.interceptList);
        this.serverUrlList = localAppInfoJson.serverlist.iterator();
        beginGetAppInfo();
    }

    @Override
    public void ShowUpdateDialog(AppVerModel appVerModel) {
        Dialog_mandatory dialog_mandatory = new Dialog_mandatory(this, appVerModel, this.updateDialogCallbackHandler);
        this.updateDialog = dialog_mandatory;
        dialog_mandatory.show();
        this.updateDialog.setCanceledOnTouchOutside(false);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        int i = displayMetrics.widthPixels;
        this.updateDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        double d = i;
        Double.isNaN(d);
        int i2 = (int) (d * 0.9d);
        int IntHight = IntHight();
        if (i2 > 972) {
            i2 = 972;
        }
        Log.i(TAG, "width px=" + i2);
        this.updateDialog.getWindow().setLayout(i2, IntHight);
    }

    private int IntHight() {
        float f = this.context.getResources().getDisplayMetrics().density - 2.0f;
        return (int) (710.4f * (f + (f >= 1.5f ? 0.3f : f >= 1.0f ? 0.53f : (f >= 1.0f || f <= 0.0f) ? f <= -1.0f ? 1.53f : f <= -0.5f ? 1.25f : 1.02f : 0.75f)));
    }

    @Override
    public void AppWebViewStart(String str) {
        OkHttpClientHelper.delOKInstance(CheckUrlStatusThread.defaultTimeout.intValue());
        AppSettingModel.getInstance().setDefaultUrl(str);
        Log.i(TAG, "AppWebViewStart " + str);
        this.webView.loadUrl(str);
    }

    @Override
    public void GoToHomePage() {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                WebViewActivity.this.m21xa3b2d1fd();
            }
        });
    }

    public void m21xa3b2d1fd() {
        this.webView.loadUrl(AppSettingModel.getInstance().getDefaultUrl());
    }

    @Override
    public void beginGetAppInfo() {
        final AppSettingModel appSettingModel = AppSettingModel.getInstance();
        appSettingModel.getAppInfoModel();
        int i = this.__getAppInfoCounter;
        if (i <= 3) {
            this.__getAppInfoCounter = i + 1;
        } else {
            this.__getAppInfoCounter = 1;
        }
        if (!this.serverUrlList.hasNext()) {
            getAppInfoError();
            return;
        }
        this.__getAppInfoUrl = this.serverUrlList.next();
        new Handler().postDelayed(new Runnable() {
            @Override
            public final void run() {
                WebViewActivity.this.m23xfcf6fc95(appSettingModel);
            }
        }, 500L);
    }

    public void m23xfcf6fc95(AppSettingModel appSettingModel) {
        Log.i(TAG, "Start GetDomainInfo url=" + this.__getAppInfoUrl + " Counter " + this.__getAppInfoCounter);
        new DomainInfoLoadThread_OKClient(this.__getAppInfoUrl, appSettingModel.getFZBH(), Tools.getUniquePsuedoID(), this.appInfoErrorHandler, this.appInfoSuccessHandler).start();
    }

    public void getAppInfoError() {
        AppSettingModel appSettingModel = AppSettingModel.getInstance();
        AppInfoModel appInfoModel = appSettingModel.getAppInfoModel();
        try {
            this.domainUrlList = appInfoModel.sitedomain;
            this.domainUrlIterator = appInfoModel.sitedomain.iterator();
            appSettingModel.setNewAppVerModel(appInfoModel.app);
        } catch (Exception e) {
            e.printStackTrace();
        }
        webViewCheckUrlStatus();
    }

    private void setCheckDesc() {
        this.__checkUrlStatusCount++;
        Log.i(TAG, "setCheckDesc " + this.__checkUrlStatusCount);
        ((TextView) findViewById(R.id.checkStatusDesc)).setText(String.format(getString(R.string.net_status_checking), Integer.valueOf(this.__checkUrlStatusCount), Integer.valueOf(this.domainUrlList.size())));
    }

    @Override
    public void beginCheckUrlStatus() {
        AppSettingModel appSettingModel = AppSettingModel.getInstance();
        this.__checkUrlCounter++;
        if (!this.domainUrlIterator.hasNext()) {
            if (appSettingModel.getAllowUseHttpDNS().booleanValue() && !appSettingModel.getEnableHttpDNS().booleanValue()) {
                Log.i(TAG, "开启HttpDns功能");
                appSettingModel.setEnableHttpDNS(true);
                this.__checkUrlCounter = 0;
                this.domainUrlIterator = this.domainUrlList.iterator();
                beginCheckUrlStatus();
                return;
            }
            OkHttpClientHelper.delOKInstance(CheckUrlStatusThread.defaultTimeout.intValue());
            showDomainInfoErrDialog(getString(R.string.tips_title_default), getString(R.string.domain_resolve_error), this.context);
            return;
        }
        this.__checkUrlValue = this.domainUrlIterator.next();
        this.urlCkeckResult = "";
        try {
            appSettingModel.setDefaultHost(new URL(this.__checkUrlValue).getHost().toLowerCase());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        setCheckDesc();
        new Handler().postDelayed(new Runnable() {
            @Override
            public final void run() {
                WebViewActivity.this.m22xd4b7f776(this);
            }
        }, 500L);
    }

    public void m22xd4b7f776(Context context) {
        Log.i(TAG, "Start CheckStatus domain:" + this.__checkUrlValue + " counter:" + this.__checkUrlCounter);
        new CheckUrlStatusThread(this.__getAppInfoUrl, this.__checkUrlValue, this.checkWebUrlStatusHandler, context).start();
    }

    @Override
    public void webViewCheckUrlStatus() {
        final AppSettingModel appSettingModel = AppSettingModel.getInstance();
        AppVerModel newAppVerModel = appSettingModel.getNewAppVerModel();
        this.__checkUrlCounter++;
        if (Tools.compareAppVer(newAppVerModel.ver, appSettingModel.getAppVersion())) {
            ShowUpdateDialog(newAppVerModel);
        } else if (this.domainUrlIterator.hasNext() && !appSettingModel.getDebuggingIP().booleanValue()) {
            this.isLoadUrlTimeOut = true;
            this.__checkUrlValue = this.domainUrlIterator.next();
            this.urlCkeckResult = "";
            try {
                appSettingModel.setDefaultHost(new URL(this.__checkUrlValue).getHost().toLowerCase());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            setCheckDesc();
            Log.i(TAG, "Start CheckStatus domain:" + this.__checkUrlValue + " counter:" + this.__checkUrlCounter);
            appSettingModel.setDefaultUrl(this.__checkUrlValue);
            AppWebViewStart(appSettingModel.getDefaultUrl());
            new Handler().postDelayed(new Runnable() {
                @Override
                public final void run() {
                    WebViewActivity.this.m26xd565b27(appSettingModel);
                }
            }, this.timeoutCheck);
        } else if (!appSettingModel.getEnableHttpDNS().booleanValue()) {
            this.__checkUrlStatusCount = 0;
            appSettingModel.setEnableHttpDNS(true);
            this.domainUrlIterator = this.domainUrlList.iterator();
            this.__checkUrlCounter = 0;
            webViewCheckUrlStatus();
        } else if (appSettingModel.getIpList().length > 0) {
            ArrayList arrayList = new ArrayList(Arrays.asList(appSettingModel.getIpList()));
            String str = (String) arrayList.remove(0);
            this.ipUrlList = arrayList.iterator();
            try {
                appSettingModel.setDefaultHost(new URL(str).getHost().toLowerCase());
            } catch (MalformedURLException e2) {
                e2.printStackTrace();
            }
            AppSettingModel.getInstance().setDefaultUrl(str);
            requestIP();
        } else {
            this.webView.stopLoading();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    CheckUrlStatusThread.sendRequestDomainFail(WebViewActivity.this.__getAppInfoUrl, AppSettingModel.getInstance().getDefaultUrl(), CheckUrlStatusThread.formatRemark(WebViewActivity.this.context, WebViewActivity.this.urlCkeckResult));
                }
            }).start();
            showDomainInfoErrDialog(getString(R.string.tips_title_default), getString(R.string.domain_resolve_error), this.context);
        }
    }

    public void m26xd565b27(AppSettingModel appSettingModel) {
        if (!isFirstSuccess.booleanValue()) {
            if (this.urlCkeckResult != "") {
                if (!this.isReconnection && this.domainUrlList.size() == 1) {
                    this.domainUrlIterator = this.domainUrlList.iterator();
                    this.isReconnection = true;
                }
            } else if (this.isLoadUrlTimeOut) {
                this.urlCkeckResult = "无法访问域名,错误原因:访问超时无响应";
                if (!this.isReconnection && this.domainUrlList.size() == 1) {
                    this.domainUrlIterator = this.domainUrlList.iterator();
                    this.isReconnection = true;
                    this.timeoutCheck = 7000L;
                }
            } else {
                this.urlCkeckResult = "加载网址成功,但站点编号核对不符,可能被劫持";
            }
            webViewCheckUrlStatus();
            return;
        }
        ((TextView) findViewById(R.id.checkStatusDesc)).setText(getString(R.string.net_status_check_finish));
        if (appSettingModel.getEnableHttpDNS().booleanValue()) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    String str = WebViewActivity.this.__getAppInfoUrl;
                    String defaultUrl = AppSettingModel.getInstance().getDefaultUrl();
                    Context context = WebViewActivity.this.context;
                    CheckUrlStatusThread.sendRequestDomainFail(str, defaultUrl, CheckUrlStatusThread.formatRemark(context, WebViewActivity.this.urlCkeckResult + "\n自定义DNS :成功"));
                }
            }).start();
        }
    }

    private void requestIP() {
        if (this.ipUrlList.hasNext()) {
            OkHttpIPHelper.request(this.context, AppSettingModel.getInstance().getDefaultUrl().replace(AppSettingModel.getInstance().getDefaultHost(), this.ipUrlList.next()), AppSettingModel.getInstance().getDefaultHost(), 5);
            return;
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                String str = WebViewActivity.this.__getAppInfoUrl;
                String defaultUrl = AppSettingModel.getInstance().getDefaultUrl();
                Context context = WebViewActivity.this.context;
                CheckUrlStatusThread.sendRequestDomainFail(str, defaultUrl, CheckUrlStatusThread.formatRemark(context, WebViewActivity.this.urlCkeckResult + "\n测试直连ip:失败"));
            }
        }).start();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                WebViewActivity webViewActivity = WebViewActivity.this;
                webViewActivity.showDomainInfoErrDialog(webViewActivity.getString(R.string.tips_title_default), WebViewActivity.this.getString(R.string.domain_resolve_error), WebViewActivity.this.context);
            }
        });
    }

    public void requestIPResult(boolean z, final String str, long j) {
        if (!z) {
            requestIP();
            return;
        }
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    AppSettingModel.getInstance().setDefaultIP(new URL(str).getHost());
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                }
                WebViewActivity.this.webView.loadUrl(AppSettingModel.getInstance().getDefaultUrl());
            }
        });
        new Thread(new Runnable() {
            @Override
            public void run() {
                String str2 = WebViewActivity.this.__getAppInfoUrl;
                String defaultUrl = AppSettingModel.getInstance().getDefaultUrl();
                Context context = WebViewActivity.this.context;
                CheckUrlStatusThread.sendRequestDomainFail(str2, defaultUrl, CheckUrlStatusThread.formatRemark(context, WebViewActivity.this.urlCkeckResult + "\n直连ip:" + AppSettingModel.getInstance().getDefaultIP() + "成功"));
            }
        }).start();
    }

    public void requestHostError(String str) {
        OkHttpClientHelper.isuseconscrypt = true;
        this.urlCkeckResult = "无法访问域名,可能被封锁或用户网路问题,APP错误原因: " + str;
    }

    @Override
    public void showDomainInfoErrDialog(String str, String str2, Context context) {
        showDomainInfoErrDialog(str, str2, context, true);
    }

    public void showDomainInfoErrDialog(String str, String str2, Context context, final Boolean bool) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(str);
        builder.setMessage(str2);
        builder.setCancelable(false);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                WebViewActivity.lambda$showDomainInfoErrDialog$4(bool, dialogInterface, i);
            }
        });
        builder.create().show();
    }

    public static void lambda$showDomainInfoErrDialog$4(Boolean bool, DialogInterface dialogInterface, int i) {
        dialogInterface.dismiss();
        if (bool.booleanValue()) {
            Process.killProcess(Process.myPid());
        }
    }

    private void initWebView() {
        AppSettingModel appSettingModel = AppSettingModel.getInstance();
        this.mProgressBar.setVisibility(0);
        WebViewCacheInterceptor.getInstance().init(new CacheBuilder(this.context).setCacheSize(104857600L).setCacheType(CacheType.FORCE));
        appSettingModel.setCurrentScreenOrientation(defaultScreenOrientation);
        if (Build.VERSION.SDK_INT >= 21) {
            CookieManager.getInstance().removeAllCookies(null);
        }
        WebSettings settings = this.webView.getSettings();
        settings.setLoadWithOverviewMode(false);
        settings.setSaveFormData(true);
        settings.setSupportZoom(true);
        settings.setBuiltInZoomControls(true);
        settings.setDisplayZoomControls(false);
        settings.setAppCacheEnabled(true);
        settings.setCacheMode(-1);
        settings.setUseWideViewPort(true);
        this.webView.setInitialScale(100);
        settings.setJavaScriptEnabled(true);
        settings.setBlockNetworkImage(false);
        settings.setDomStorageEnabled(true);
        settings.setCacheMode(2);
        settings.setUserAgentString(settings.getUserAgentString() + " GTMobileApp/" + appSettingModel.getAppVersion());
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        if (Build.VERSION.SDK_INT >= 21) {
            settings.setMixedContentMode(0);
        }
        settings.setTextZoom(100);
        MyWebChromeClient myWebChromeClient = new MyWebChromeClient(this);
        this.mWebChromeClient = myWebChromeClient;
        this.webView.setWebChromeClient(myWebChromeClient);
        WebView.setWebContentsDebuggingEnabled(appSettingModel.getDebuggingEnabled().booleanValue());
        this.webView.setWebViewClient(new InterceptingWebViewClient(this, this.webView) {
            @Override
            public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
                super.onPageStarted(webView, str, bitmap);
            }

            @Override
            public void onPageFinished(WebView webView, String str) {
                super.onPageFinished(webView, str);
                if (Tools.isFirstStrart(WebViewActivity.this.context)) {
                    try {
                        OkHttpDataHelper.requestFirstStart(WebViewActivity.this.context, WebViewActivity.this.__getAppInfoUrl, AppSettingModel.getInstance().getFZBH(), Tools.getDeviceID(WebViewActivity.this.context), 5);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                WebViewActivity.this.webView.loadUrl("javascript:document.documentElement.webkitRequestFullscreen = null;");
            }

            @Override
            public void onReceivedError(WebView webView, int i, String str, String str2) {
                Log.i(WebViewActivity.TAG, "onReceivedError " + i);
                if (!WebViewActivity.isFirstSuccess.booleanValue()) {
                    WebViewActivity.this.webView.loadUrl(AppSettingModel.getInstance().getDefaultUrl());
                    return;
                }
                try {
                    WebView webView2 = WebViewActivity.this.webView;
                    webView2.loadUrl(AppSettingModel.getInstance().getNetWorkErrorUrl() + "?name=" + URLEncoder.encode(AppSettingModel.getInstance().getAPPName(), "utf-8") + "&view=webview");
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
                if (sslErrorHandler != null) {
                    sslErrorHandler.proceed();
                } else {
                    super.onReceivedSslError(webView, null, sslError);
                }
            }
        });
        this.webView.clearCache(true);
    }

    @Override
    public void hindProgressBar() {
        this.mProgressBar.setVisibility(8);
    }

    @Override
    public void showWebView() {
        this.webView.setVisibility(0);
    }

    @Override
    public void hindWebView() {
        this.webView.setVisibility(4);
    }

    @Override
    public void fullViewAddView(View view) {
        FullscreenHolder fullscreenHolder = new FullscreenHolder(this);
        this.videoFullView = fullscreenHolder;
        fullscreenHolder.addView(view);
        ((FrameLayout) getWindow().getDecorView()).addView(this.videoFullView);
    }

    @Override
    public void showVideoFullView() {
        this.videoFullView.setVisibility(0);
    }

    @Override
    public void hindVideoFullView() {
        this.videoFullView.setVisibility(8);
    }

    @Override
    public void startProgress(int i) {
        if (isFirstSuccess.booleanValue()) {
            this.mProgressBar.setVisibility(0);
            this.mProgressBar.setProgress(i);
            this.webView.loadUrl("javascript:(function(){var head = document.getElementsByTagName('head');if(head.length==0)return;var or = document.querySelector('meta[name=cashapp-screen-orientation]');if(or){var val = or.getAttribute('content');CashApp.changeScreenOrientation(val);}else{CashApp.changeScreenOrientation('');}})()");
            if (i == 100) {
                this.mProgressBar.setVisibility(8);
            }
        }
    }

    @Override
    public void changeScreenOrientation(String str) {
        if (AppSettingModel.getInstance().getCurrentScreenOrientation().equals(str)) {
            return;
        }
        str.hashCode();
        if (str.equals("LANDSCAPE")) {
            setRequestedOrientation(6);
        } else if (str.equals("PORTRAIT")) {
            setRequestedOrientation(7);
        } else {
            setRequestedOrientation(10);
        }
        AppSettingModel.getInstance().setCurrentScreenOrientation(str);
    }

    public void hideCustomView() {
        setRequestedOrientation(1);
    }

    @Override
    protected void onActivityResult(int i, int i2, Intent intent) {
        if (i == MyWebChromeClient.FILECHOOSER_RESULTCODE) {
            this.mWebChromeClient.mUploadMessage(intent, i2);
        } else if (i == MyWebChromeClient.FILECHOOSER_RESULTCODE_FOR_ANDROID_5) {
            this.mWebChromeClient.mUploadMessageForAndroid5(intent, i2);
        }
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            if (this.mWebChromeClient.inCustomView()) {
                hideCustomView();
                return true;
            } else if (this.webView.canGoBack()) {
                this.webView.goBack();
                return true;
            } else {
                return super.onKeyDown(i, keyEvent);
            }
        }
        return false;
    }

    @Override
    public void onPause() {
        super.onPause();
        this.webView.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        this.webView.onResume();
        this.webView.resumeTimers();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.videoFullView.removeAllViews();
        WebView webView = this.webView;
        if (webView != null) {
            ViewGroup viewGroup = (ViewGroup) webView.getParent();
            if (viewGroup != null) {
                viewGroup.removeView(this.webView);
            }
            this.webView.removeAllViews();
            this.webView.stopLoading();
            this.webView.setWebChromeClient(null);
            this.webView.setWebViewClient(null);
            this.webView.destroy();
            this.webView = null;
        }
        this.appInfoErrorHandler.removeCallbacksAndMessages(null);
    }

    @Override
    public void onBackPressed() {
        if (this.webView.canGoBack()) {
            this.webView.goBack();
        } else {
            new AlertDialog.Builder(this).setIcon(17301543).setTitle(getString(R.string.tips_title_default)).setMessage(getString(R.string.back_pressed_text)).setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    WebViewActivity.this.m25xdf41c2f3(dialogInterface, i);
                }
            }).setNegativeButton(getString(R.string.cancel), (DialogInterface.OnClickListener) null).show();
        }
    }

    public void m25xdf41c2f3(DialogInterface dialogInterface, int i) {
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.HOME");
        intent.setFlags(67108864);
        startActivity(intent);
        Process.killProcess(Process.myPid());
    }

    public class AnonymousClass8 extends Thread {
        final JSONObject val$finalData;
        final String val$method;
        final String val$req_id;
        final String val$url;

        AnonymousClass8(String str, String str2, JSONObject jSONObject, String str3) {
            this.val$url = str;
            this.val$method = str2;
            this.val$finalData = jSONObject;
            this.val$req_id = str3;
        }

        @Override
        public void run() {
            try {
                final Response request = OkHttpClientHelper.request(this.val$url, this.val$method, this.val$finalData);
                final int code = request.code();
                final String lowerCase = request.body().contentType().toString().toLowerCase();
                WebViewActivity webViewActivity = WebViewActivity.this;
                final String str = this.val$req_id;
                final String str2 = this.val$url;
                webViewActivity.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        WebViewActivity.AnonymousClass8.this.m27x49f0d2f1(code, lowerCase, request, str, str2);
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
                WebView webView = WebViewActivity.this.webView;
                webView.loadUrl("javascript:JsBridage.CustomAjaxCallBack('" + this.val$req_id + "','" + e.getMessage() + "',false)");
            }
        }

        public void m27x49f0d2f1(int i, String str, Response response, String str2, String str3) {
            if (i == 200) {
                try {
                    if (str.contains("application/octet-stream")) {
                        byte[] bytes = response.body().bytes();
                        WebView webView = WebViewActivity.this.webView;
                        webView.loadUrl("javascript:JsBridage.CustomAjaxCallBack('" + str2 + "'," + Arrays.toString(bytes) + ",true)");
                    } else if (str.contains("text/html")) {
                        String string = response.body().string();
                        WebView webView2 = WebViewActivity.this.webView;
                        webView2.loadUrl("javascript:JsBridage.CustomAjaxCallBack('" + str2 + "','" + string + "',true)");
                    } else {
                        String string2 = response.body().string();
                        WebView webView3 = WebViewActivity.this.webView;
                        webView3.loadUrl("javascript:JsBridage.CustomAjaxCallBack('" + str2 + "'," + string2 + ",true)");
                    }
                    return;
                } catch (Exception e) {
                    e.printStackTrace();
                    WebView webView4 = WebViewActivity.this.webView;
                    webView4.loadUrl("javascript:JsBridage.CustomAjaxCallBack('" + str2 + "'," + e.getMessage() + ",false)");
                    return;
                }
            }
            Log.i(WebViewActivity.TAG, "JsBridage.CustomAjax " + str3 + " fail " + i);
            WebView webView5 = WebViewActivity.this.webView;
            webView5.loadUrl("javascript:JsBridage.CustomAjaxCallBack('" + str2 + "'," + i + ",false)");
        }
    }

    @Override
    public void request(String str, String str2, String str3, JSONObject jSONObject) {
        new AnonymousClass8(str2, str3, jSONObject, str).start();
    }

    public void checkMetaMD5(final String str) {
        this.isLoadUrlTimeOut = false;
        if (isFirstSuccess.booleanValue()) {
            return;
        }
        final AppSettingModel appSettingModel = AppSettingModel.getInstance();
        final String mD5Str = Tools.getMD5Str(appSettingModel.getFZBH_API());
        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public final void run() {
                WebViewActivity.this.m24x10829c63(mD5Str, str, appSettingModel);
            }
        }, 100L);
    }

    public void m24x10829c63(String str, String str2, AppSettingModel appSettingModel) {
        boolean contains = this.webView.getUrl().contains("403.html");
        Log.d("checkMetaMD5", "result=" + str.equals(str2) + " is403Error=" + contains);
        if (str.equals(str2) || contains || str2.equals(appSettingModel.getFZBH_API())) {
            isFirstSuccess = true;
            this.webView.setVisibility(0);
            findViewById(R.id.lunchscreen_bg).setVisibility(8);
            findViewById(R.id.checkStatusDesc).setVisibility(8);
            findViewById(R.id.text_AppVersion).setVisibility(8);
            Handler handler = this.detectionMD5Handler;
            if (handler != null) {
                handler.removeMessages(1);
            }
        }
    }

    public void setSavePsData(String str, String str2, boolean z) {
        SharedPreferences.Editor edit = getSharedPreferences("accountPass", 0).edit();
        edit.putString("account", str);
        edit.putString("pass", str2);
        edit.putBoolean("save", z);
        edit.apply();
    }

    public String getSavePsData() {
        SharedPreferences sharedPreferences = getSharedPreferences("accountPass", 0);
        String string = sharedPreferences.getString("account", "");
        String string2 = sharedPreferences.getString("pass", "");
        boolean z = sharedPreferences.getBoolean("save", false);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("account", string);
            jSONObject.put("pass", string2);
            jSONObject.put("save", z);
            return jSONObject.toString();
        } catch (JSONException e) {
            e.printStackTrace();
            return "";
        }
    }
}