优赢国际.apk(点击下载) / JDCWebViewActivity.java


package com.fob.ds.activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import butterknife.BindView;
import cn.jiguang.net.HttpUtils;
import com.bumptech.glide.load.n.i;
import com.flb.zj.omkxm.R;
import com.fob.ds.domain.JDCGameBean;
import d.b.a.q.e;
import d.d.a.j.b0;
import d.d.a.j.p;
import d.d.a.j.p0;
import java.util.HashMap;
import java.util.Map;

public class JDCWebViewActivity extends com.fob.ds.base.a {
    private ValueCallback<Uri> B;
    private ValueCallback<Uri[]> C;
    private String D = "确定要离开游戏吗?";
    private String F;
    private String G;
    boolean H = true;
    @BindView
    ImageView iv_gift;
    @BindView
    RelativeLayout rl_gift_root;
    @BindView
    WebView wv_web_view;

    class a extends WebChromeClient {
        a(JDCWebViewActivity jDCWebViewActivity) {
        }

        public void onProgressChanged(WebView webView, int i) {
            d.d.a.g.c.c("--------------" + i);
            super.onProgressChanged(webView, i);
        }

        public void onReceivedTitle(WebView webView, String str) {
            super.onReceivedTitle(webView, str);
            d.d.a.g.c.c("----- title " + str);
        }
    }

    class c extends WebChromeClient {
        c() {
        }

        public void onProgressChanged(WebView webView, int i) {
            if (i == 100) {
                JDCWebViewActivity.this.rl_gift_root.setVisibility(8);
            } else {
                JDCWebViewActivity jDCWebViewActivity = JDCWebViewActivity.this;
                if (jDCWebViewActivity.H) {
                    jDCWebViewActivity.H = false;
                    jDCWebViewActivity.rl_gift_root.setVisibility(0);
                }
            }
            super.onProgressChanged(webView, i);
        }

        public void onReceivedTitle(WebView webView, String str) {
            super.onReceivedTitle(webView, str);
        }

        @Override // android.webkit.WebChromeClient
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
            JDCWebViewActivity.this.C = valueCallback;
            Intent intent = new Intent("android.intent.action.GET_CONTENT");
            intent.addCategory("android.intent.category.OPENABLE");
            intent.setType("*/*");
            JDCWebViewActivity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 0);
            return true;
        }
    }

    class d implements DialogInterface.OnClickListener {
        d() {
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            JDCWebViewActivity.this.finish();
        }
    }

    public static final String X(HashMap<String, String> hashMap) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> entry : hashMap.entrySet()) {
            sb.append(entry.getKey());
            sb.append(HttpUtils.EQUAL_SIGN);
            sb.append(Uri.encode(entry.getValue(), HttpUtils.ENCODING_UTF_8));
            sb.append(HttpUtils.PARAMETERS_SEPARATOR);
        }
        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }

    /* access modifiers changed from: protected */
    @Override // com.fob.ds.base.a
    public int K() {
        return R.layout.activity_jdc_web_view;
    }

    /* access modifiers changed from: protected */
    @Override // com.fob.ds.base.a
    public void N(Bundle bundle) {
        JDCGameBean jDCGameBean = (JDCGameBean) getIntent().getSerializableExtra("jdcGfc");
        boolean booleanExtra = getIntent().getBooleanExtra("isChat", false);
        String stringExtra = getIntent().getStringExtra("type");
        if (jDCGameBean == null) {
            finish();
            return;
        }
        e f2 = new e().f(i.a);
        d.b.a.i<Drawable> r = d.b.a.c.w(this).r(Integer.valueOf((int) R.drawable.icon_jd_gift));
        r.b(f2);
        r.l(this.iv_gift);
        stringExtra.hashCode();
        if (stringExtra.equals("gfc")) {
            this.D = "确定要离开官方彩吗?";
        } else if (stringExtra.equals("jdc")) {
            this.D = "确定要离开经典彩吗?";
        }
        int i = Build.VERSION.SDK_INT;
        if (i < 17) {
            this.wv_web_view.removeJavascriptInterface("searchBoxJavaBridge_");
        }
        if (i < 19) {
            this.wv_web_view.removeJavascriptInterface("accessibilityTraversal");
            this.wv_web_view.removeJavascriptInterface("accessibility");
        }
        if (i >= 21) {
            this.wv_web_view.getSettings().setMixedContentMode(0);
        }
        WebSettings settings = this.wv_web_view.getSettings();
        settings.setUserAgentString("APP_JDC_Anroid " + settings.getUserAgentString());
        p0.b(this.wv_web_view);
        this.wv_web_view.setWebChromeClient(new a(this));
        this.wv_web_view.setWebViewClient(new b());
        this.wv_web_view.setWebChromeClient(new c());
        String str = jDCGameBean.getData().getUrl().get(0);
        this.F = str;
        if (str.startsWith("http")) {
            String platformURL = jDCGameBean.getData().getPlatformURL();
            String clientType = jDCGameBean.getData().getClientType();
            HashMap hashMap = new HashMap();
            if (b0.a(platformURL)) {
                platformURL = "";
            }
            hashMap.put("platformURL", platformURL);
            hashMap.put("lid", jDCGameBean.getData().getLid());
            hashMap.put("r", jDCGameBean.getData().getParams().getR());
            hashMap.put("param", jDCGameBean.getData().getParams().getParam());
            hashMap.put("encrypt", jDCGameBean.getData().getParams().getEncrypt());
            if (!b0.a(clientType)) {
                hashMap.put("clientType", clientType);
            }
            if (booleanExtra) {
                hashMap.put("loginType", "cr");
            }
            this.G = X(hashMap);
            d.d.a.g.c.a(this.F + "   " + this.G);
            this.wv_web_view.postUrl(this.F, this.G.getBytes());
            return;
        }
        finish();
    }

    @Override // android.support.v4.app.g
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i2 != -1 || i != 0) {
            return;
        }
        if (Build.VERSION.SDK_INT >= 21) {
            if (intent != null) {
                this.C.onReceiveValue(new Uri[]{intent.getData()});
            }
        } else if (intent != null) {
            this.B.onReceiveValue(intent.getData());
        }
    }

    @Override // android.support.v7.app.c
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        p.e(this, this.D, new d());
        return false;
    }

    class b extends WebViewClient {
        b() {
        }

        public void onPageFinished(WebView webView, String str) {
            d.d.a.g.c.c("------------Finish:" + str);
            super.onPageFinished(webView, str);
        }

        @Override // android.webkit.WebViewClient
        public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
            if (Build.VERSION.SDK_INT >= 21) {
                d.d.a.g.c.c("-------Newurl : " + webResourceRequest.getUrl().toString());
            } else {
                d.d.a.g.c.c("-------Newurl : " + webResourceRequest.toString());
            }
            return super.shouldOverrideUrlLoading(webView, webResourceRequest);
        }

        @Override // android.webkit.WebViewClient
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            d.d.a.g.c.c("-------Newurl : " + str);
            if (str != null && str.equals("http://www.jdc.com/close")) {
                JDCWebViewActivity.this.finish();
                return true;
            } else if (str != null && str.equals("about:blank")) {
                JDCWebViewActivity.this.finish();
                return true;
            } else if (str == null || !str.equals("http://www.jdc.com/login")) {
                webView.loadUrl(str);
                return true;
            } else {
                webView.postUrl(JDCWebViewActivity.this.F, JDCWebViewActivity.this.G.getBytes());
                return true;
            }
        }
    }
}