翰林优商.apk(点击下载) / SaasH5Activity.java


package com.tb.mob.saas;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import com.baidu.idl.face.platform.FaceEnvironment;
import com.tb.mob.R;
import com.tb.mob.utils.MyWebChromeClient;
import com.tb.mob.utils.MyWebViewClient;
import com.tb.mob.utils.RequestPermission;
import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;

public class SaasH5Activity extends Activity {
    private static Handler f = new Handler(Looper.getMainLooper());
    private WebView a;
    private String b;
    private String c;
    private ValueCallback<Uri> d;
    private ValueCallback<Uri[]> e;
    public boolean isBackPressedSupport = true;

    public class JsInteration {
        public JsInteration() {
        }

        @JavascriptInterface
        public void loadSaasAdData(String str) {
            Log.d("loadSaasAdData", str);
            SaasUtils.loadSaasAdData(SaasH5Activity.this.b, SaasH5Activity.this.c, SaasH5Activity.this.a, SaasH5Activity.this, str);
        }
    }

    private void a() {
        WebView webView = (WebView) findViewById(R.id.a_webView);
        this.a = webView;
        WebSettings settings = webView.getSettings();
        String userAgentString = settings.getUserAgentString();
        settings.setUserAgentString(userAgentString + "; tbMobSDK");
        settings.setJavaScriptEnabled(true);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setSupportZoom(true);
        settings.setBuiltInZoomControls(true);
        settings.setDisplayZoomControls(false);
        settings.setAllowFileAccess(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setLoadsImagesAutomatically(true);
        settings.setDefaultTextEncodingName("utf-8");
        settings.setCacheMode(-1);
        settings.setDomStorageEnabled(true);
        settings.setDatabaseEnabled(true);
        settings.setAppCacheEnabled(true);
        settings.setSaveFormData(false);
        settings.setAppCachePath(getFilesDir().getAbsolutePath() + "00_TB_MOB_SDK");
        if (Build.VERSION.SDK_INT >= 21) {
            settings.setMixedContentMode(0);
        }
        this.a.addJavascriptInterface(new JsInteration(), FaceEnvironment.OS);
        this.a.setWebViewClient(new MyWebViewClient(this));
        this.a.setWebChromeClient(new MyWebChromeClient(this));
        this.a.loadUrl(SaasConfigInfo.h5Url);
    }

    private void a(final WebView webView, final String str, final String str2) {
        f.post(new Runnable(this) {
            /* class com.tb.mob.saas.SaasH5Activity.AnonymousClass1 */

            public void run() {
                ValueCallback<String> valueCallback;
                String str;
                WebView webView;
                String str2;
                WebView webView2;
                if (Build.VERSION.SDK_INT < 18) {
                    if (TextUtils.isEmpty(str2)) {
                        webView2 = webView;
                        str2 = "javascript:" + str + "()";
                    } else {
                        webView2 = webView;
                        str2 = "javascript:" + str + "(" + str2 + ")";
                    }
                    webView2.loadUrl(str2);
                    return;
                }
                if (TextUtils.isEmpty(str2)) {
                    webView = webView;
                    str = "javascript:" + str + "()";
                    valueCallback = new ValueCallback<String>(this) {
                        /* class com.tb.mob.saas.SaasH5Activity.AnonymousClass1.AnonymousClass1 */

                        public void onReceiveValue(String str) {
                        }
                    };
                } else {
                    webView = webView;
                    str = "javascript:" + str + "(" + str2 + ")";
                    valueCallback = new ValueCallback<String>(this) {
                        /* class com.tb.mob.saas.SaasH5Activity.AnonymousClass1.AnonymousClass2 */

                        public void onReceiveValue(String str) {
                        }
                    };
                }
                webView.evaluateJavascript(str, valueCallback);
            }
        });
    }

    /* access modifiers changed from: protected */
    public void onActivityResult(int i, int i2, Intent intent) {
        ValueCallback<Uri> valueCallback;
        super.onActivityResult(i, i2, intent);
        if (i == 0) {
            if (i2 == -1) {
                if (this.d != null) {
                    this.d.onReceiveValue(intent == null ? null : intent.getData());
                    this.d = null;
                }
                if (this.e != null) {
                    this.e.onReceiveValue(new Uri[]{intent == null ? null : intent.getData()});
                    this.e = null;
                }
            } else if (i2 == 0 && (valueCallback = this.d) != null) {
                valueCallback.onReceiveValue(null);
                this.d = null;
            }
        } else if (i == 200 && i2 == 200) {
            a(this.a, intent.getExtras().getString("callBack"), "");
        }
    }

    public void onBackPressed() {
        if (!this.a.canGoBack() || !this.isBackPressedSupport) {
            super.onBackPressed();
        } else {
            this.a.goBack();
        }
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        requestWindowFeature(1);
        this.b = getIntent().getStringExtra("moduleGroupId");
        this.c = getIntent().getStringExtra("userId");
        setContentView(R.layout.saas_activity_saas_h5);
        ViewGroup viewGroup = (ViewGroup) findViewById(R.id.a_container);
        RequestPermission.RequestPermissionIfNecessary(this);
        a();
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        super.onPause();
        this.a.onPause();
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        this.a.onResume();
    }
}