流利说-英语 v8.47.26版本的 MD5 值为:0079dce5ff96e6cdbc95c261b3f51387

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


package com.geetest.sdk.dialog.views;

import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import com.geetest.sdk.ap;
import com.geetest.sdk.ar;
import com.geetest.sdk.r;
import com.geetest.sdk.utils.e;
import com.geetest.sdk.utils.h;
import com.huawei.hms.framework.common.ContainerUtils;
import com.sensorsdata.analytics.android.sdk.jsbridge.JSHookAop;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class a {
    private static final String m = "a";
    public static int n;
    public static int o;
    private com.geetest.sdk.a.a.c Of;
    private com.geetest.sdk.b Og;
    private r Oh;
    private Runnable Oj;

    private Context f1463a;
    private int e;
    private int f;
    private int h;
    private String j;
    private GT3GtWebView Oi = null;
    private Handler Ok = new c();
    private ap Oe = new ap();

    public class b {

        class RunnableC0081a implements Runnable {

            final int f1464a;

            final String f1465b;

            RunnableC0081a(int i, String str) {
                this.f1464a = i;
                this.f1465b = str;
            }

            @Override
            public void run() {
                if (a.this.Og == null || a.this.Og.mL() == null) {
                    h.b(a.m, "configBean is null !");
                } else {
                    a.this.Og.mL().aT(this.f1464a);
                }
                if (a.this.Oe != null) {
                    if (this.f1464a == 1) {
                        a.this.Oe.a(true, this.f1465b);
                    } else {
                        a.this.c();
                    }
                }
            }
        }

        class RunnableC0082b implements Runnable {
            RunnableC0082b() {
            }

            @Override
            public void run() {
                if (a.this.Oi == null || a.this.Oi.b()) {
                    return;
                }
                if (a.this.Ok != null) {
                    try {
                        a.this.Ok.removeCallbacks(a.this.Oj);
                        a.this.Ok.removeMessages(1);
                    } catch (Exception unused) {
                    }
                }
                if (a.this.Oe != null) {
                    a.this.Oe.a();
                }
            }
        }

        class c implements Runnable {

            final String f1466a;

            c(String str) {
                this.f1466a = str;
            }

            @Override
            public void run() {
                try {
                    JSONObject jSONObject = new JSONObject(this.f1466a);
                    a.this.Oe.a(jSONObject.getString("error_code").replaceAll("[a-zA-Z]", ""), jSONObject.getString("user_error"));
                } catch (JSONException e) {
                    e.printStackTrace();
                    a.this.Oe.a("202", this.f1466a + "-->" + e.toString());
                }
            }
        }

        class d implements Runnable {
            d() {
            }

            @Override
            public void run() {
                a.this.Oi.setVoice(true);
                a.this.Of.i("voice");
                int a2 = e.a(a.this.f1463a);
                int b2 = e.b(a.this.f1463a);
                int a3 = com.geetest.sdk.utils.c.a(a.this.f1463a, 275.0f);
                int a4 = com.geetest.sdk.utils.c.a(a.this.f1463a, 348.0f);
                int a5 = com.geetest.sdk.utils.c.a(a.this.f1463a, 300.0f);
                if (a.this.f1463a.getResources().getConfiguration().orientation != 1) {
                    int a6 = com.geetest.sdk.utils.c.a(a.this.f1463a, com.geetest.sdk.utils.c.b(a.this.f1463a, a2) - 44);
                    if (a6 >= a3) {
                        a3 = a6;
                    }
                    if (a6 > a4) {
                        a3 = a4;
                    }
                    a.o = a3;
                    a.n = (a3 * 100) / a.this.h;
                } else {
                    int i = (b2 * 4) / 5;
                    if (i >= a5) {
                        a5 = i;
                    }
                    if (i <= a4) {
                        a4 = a5;
                    }
                    a.n = a4;
                    a.o = (a4 * a.this.h) / 100;
                }
                if (a.this.Oi != null && a.this.Oi.getLayoutParams() != null) {
                    ViewGroup.LayoutParams layoutParams = a.this.Oi.getLayoutParams();
                    layoutParams.width = a.n;
                    layoutParams.height = a.o;
                    a.this.Oi.setLayoutParams(layoutParams);
                }
                if (a.this.Oh != null) {
                    com.geetest.sdk.utils.a.f1482a = true;
                    a.this.Oh.show();
                }
                com.geetest.sdk.utils.a.f1482a = false;
            }
        }

        private b() {
        }

        @JavascriptInterface
        public void gt3Error(String str) {
            h.b("JSInterface-->gt3Error", str);
            if (a.this.Ok != null) {
                try {
                    a.this.Ok.removeCallbacks(a.this.Oj);
                    a.this.Ok.removeMessages(1);
                } catch (Exception unused) {
                }
            }
            if (a.this.Oe == null || a.this.f1463a == null || !(a.this.f1463a instanceof Activity)) {
                return;
            }
            ((Activity) a.this.f1463a).runOnUiThread(new c(str));
        }

        @JavascriptInterface
        public void gtCallBack(String str, String str2, String str3) {
            h.b(a.m, "JSInterface-->gtCallBack-->code: " + str + ", message: " + str3);
            h.d(a.m, "JSInterface-->gtCallBack-->code: " + str + ", result: " + str2 + ", message: " + str3);
            try {
                int parseInt = Integer.parseInt(str);
                if (a.this.f1463a == null || ((Activity) a.this.f1463a).isFinishing()) {
                    return;
                }
                ((Activity) a.this.f1463a).runOnUiThread(new RunnableC0081a(parseInt, str2));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }

        @JavascriptInterface
        public void gtClose() {
            h.b(a.m, "JSInterface-->gtClose");
            if (a.this.Oe != null) {
                a.this.Oe.b();
            }
        }

        @JavascriptInterface
        public void gtNotify(String str) {
            h.b(a.m, "JSInterface-->gtNotify-->" + str);
            try {
                a.this.h = Integer.parseInt(new JSONObject(str).getString("aspect_radio"));
                if (a.this.f1463a == null || ((Activity) a.this.f1463a).isFinishing()) {
                    return;
                }
                ((Activity) a.this.f1463a).runOnUiThread(new d());
            } catch (Exception e) {
                e.printStackTrace();
                a.this.Oe.a("202", "parse aspect_radio failed-->" + e.toString());
            }
        }

        @JavascriptInterface
        public void gtReady() {
            h.b(a.m, "JSInterface-->gtReady");
            if (a.this.f1463a == null || !(a.this.f1463a instanceof Activity)) {
                return;
            }
            ((Activity) a.this.f1463a).runOnUiThread(new RunnableC0082b());
        }
    }

    public class c extends Handler {
        public c() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what != 1 || a.this.Oe == null) {
                return;
            }
            h.b(a.m, String.format("handleMessage-->timeout %s !", Integer.valueOf(a.this.Of.o())));
            a.this.Oe.a("204", "load static resource timeout !");
        }
    }

    public class d implements Runnable {
        public d() {
        }

        @Override
        public void run() {
            Message message = new Message();
            message.what = 1;
            a.this.Ok.sendMessage(message);
        }
    }

    public a(Context context, r rVar) {
        this.f1463a = context;
        this.Oh = rVar;
    }

    private float f() {
        return this.f1463a.getResources().getDisplayMetrics().density;
    }

    private int g() {
        int i;
        int i2;
        int a2 = e.a(this.f1463a);
        int b2 = e.b(this.f1463a);
        int a3 = com.geetest.sdk.utils.c.a(this.f1463a, 300.0f);
        int a4 = com.geetest.sdk.utils.c.a(this.f1463a, 275.0f);
        int a5 = com.geetest.sdk.utils.c.a(this.f1463a, 410.0f);
        int a6 = com.geetest.sdk.utils.c.a(this.f1463a, 348.0f);
        h.d(m, "widthScreen: " + com.geetest.sdk.utils.c.b(this.f1463a, b2));
        if (a2 < b2) {
            i = (a2 * 4) / 5;
        } else {
            i = (b2 * 4) / 5;
        }
        if ("beeline".equals(this.Of.m()) || (i2 = this.h) <= 60) {
            this.e = a3;
            this.f = (a3 * this.h) / 100;
        } else if (i2 >= 100) {
            if (!"slide".equals(this.Of.m()) || Build.VERSION.SDK_INT >= 19) {
                if (a2 < b2) {
                    int a7 = com.geetest.sdk.utils.c.a(this.f1463a, com.geetest.sdk.utils.c.b(r3, a2) - 44);
                    h.b(m, "limitationWidth:  " + a7);
                    if (com.geetest.sdk.utils.d.b(this.f1463a)) {
                        if (a7 >= a4) {
                            a4 = a7;
                        }
                        if (a7 <= a5) {
                            i = a4;
                        }
                    } else {
                        a5 = a7 < a4 ? a4 : a7;
                    }
                } else {
                    a5 = i < a3 ? a3 : i;
                }
                if (a2 < b2) {
                    this.e = (i * 100) / this.h;
                    this.f = i;
                } else {
                    this.e = i;
                    this.f = (this.h * i) / 100;
                }
            } else {
                float f = f();
                h.d(m, "scale: " + f);
                int a8 = com.geetest.sdk.utils.c.a(this.f1463a, 210.0f);
                int a9 = com.geetest.sdk.utils.c.a(this.f1463a, 230.0f);
                int a10 = com.geetest.sdk.utils.c.a(this.f1463a, 250.0f);
                int a11 = com.geetest.sdk.utils.c.a(this.f1463a, 270.0f);
                int a12 = com.geetest.sdk.utils.c.a(this.f1463a, 280.0f);
                int a13 = com.geetest.sdk.utils.c.a(this.f1463a, 340.0f);
                double d2 = f;
                if (d2 <= 1.5d) {
                    if (i >= a8) {
                        a8 = i;
                    }
                    if (i <= a4) {
                        a4 = a8;
                    }
                } else {
                    if (d2 <= 2.0d) {
                        if (i >= a9) {
                            a9 = i;
                        }
                        if (i > a12) {
                            a5 = a12;
                        } else {
                            a4 = a9;
                        }
                    } else if (d2 <= 3.0d) {
                        a4 = i < a10 ? a10 : i;
                        if (i > a13) {
                            a4 = a13;
                        }
                    } else {
                        a4 = i < a11 ? a11 : i;
                        if (i > a6) {
                            a5 = a6;
                        }
                    }
                    if (a2 < b2) {
                    }
                }
                a5 = a4;
            }
            i = a5;
            if (a2 < b2) {
            }
        } else if (a2 < b2) {
            int a14 = com.geetest.sdk.utils.c.a(this.f1463a, com.geetest.sdk.utils.c.b(r2, a2) - 44);
            if (a14 >= a4) {
                a4 = a14;
            }
            if (a14 <= a6) {
                i = a4;
                this.e = i;
                this.f = (this.h * i) / 100;
            }
            i = a6;
            this.e = i;
            this.f = (this.h * i) / 100;
        } else {
            if (i >= a3) {
                a3 = i;
            }
            if (i <= a6) {
                i = a3;
                this.e = i;
                this.f = (this.h * i) / 100;
            }
            i = a6;
            this.e = i;
            this.f = (this.h * i) / 100;
        }
        h.d(m, "widthPX: " + i);
        h.d(m, "widthDP: " + com.geetest.sdk.utils.c.b(this.f1463a, i));
        h.d(m, "height:  " + this.h);
        h.d(m, "mWidth:  " + this.e);
        h.d(m, "mHeight:  " + this.f);
        String str = m;
        StringBuilder sb = new StringBuilder();
        sb.append("deviceWidth: ");
        sb.append(com.geetest.sdk.utils.c.b(this.f1463a, e.b(r3)));
        h.d(str, sb.toString());
        String str2 = m;
        StringBuilder sb2 = new StringBuilder();
        sb2.append("deviceHeight: ");
        sb2.append(com.geetest.sdk.utils.c.b(this.f1463a, e.a(r3)));
        h.d(str2, sb2.toString());
        return i;
    }

    public void b() {
        GT3GtWebView gT3GtWebView = this.Oi;
        if (gT3GtWebView != null) {
            gT3GtWebView.removeJavascriptInterface("JSInterface");
            ViewGroup viewGroup = (ViewGroup) this.Oi.getParent();
            if (viewGroup != null) {
                viewGroup.removeView(this.Oi);
            }
            this.Oi.removeAllViews();
            this.Oi.destroy();
            this.Oi = null;
        }
        try {
            if (this.Ok != null) {
                this.Ok.removeCallbacks(this.Oj);
                this.Ok.removeMessages(1);
                this.Ok = null;
            }
        } catch (Exception unused) {
        }
    }

    public void c() {
        GT3GtWebView gT3GtWebView = this.Oi;
        if (gT3GtWebView != null) {
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(gT3GtWebView, "translationX", 0.0f, 2.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, -2.0f, 0.0f, 2.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, -2.0f, 0.0f);
            ofFloat.setDuration(500L);
            ofFloat.start();
        }
    }

    public void d() {
        g();
        GT3GtWebView gT3GtWebView = this.Oi;
        if (gT3GtWebView == null || gT3GtWebView.getLayoutParams() == null) {
            return;
        }
        n = this.e;
        o = this.f;
        ViewGroup.LayoutParams layoutParams = this.Oi.getLayoutParams();
        layoutParams.width = n;
        layoutParams.height = o;
        this.Oi.setLayoutParams(layoutParams);
    }

    public void a(ar arVar) {
        this.Oe.a(arVar);
    }

    public void b(com.geetest.sdk.a.a.c cVar) {
        this.Of = cVar;
    }

    public void b(com.geetest.sdk.b bVar) {
        this.Og = bVar;
    }

    public GT3GtWebView mY() {
        String str;
        String str2;
        String str3;
        new HashMap();
        this.h = this.Of.j();
        new HashMap();
        Map<String, Integer> a2 = this.Of.nj().a();
        if (a2 == null || a2.size() <= 0) {
            str = "";
            str2 = str;
        } else {
            str = "";
            str2 = str;
            for (Map.Entry<String, Integer> entry : a2.entrySet()) {
                if (!TextUtils.isEmpty(entry.getKey())) {
                    str2 = str2 + "&aspect_radio_" + entry.getKey() + ContainerUtils.KEY_VALUE_DELIMITER + entry.getValue();
                    str = str + ContainerUtils.FIELD_DELIMITER + entry.getKey() + ContainerUtils.KEY_VALUE_DELIMITER + this.Of.nj().b().optString(entry.getKey());
                }
            }
        }
        Map<String, String> c2 = this.Of.c();
        if (c2 == null || c2.size() <= 0) {
            str3 = "";
        } else {
            str3 = "";
            for (Map.Entry<String, String> entry2 : c2.entrySet()) {
                if (!TextUtils.isEmpty(entry2.getKey())) {
                    str3 = str3 + ContainerUtils.FIELD_DELIMITER + entry2.getKey() + ContainerUtils.KEY_VALUE_DELIMITER + entry2.getValue();
                }
            }
        }
        this.j = "?gt=" + this.Of.i() + "&challenge=" + this.Of.b() + "&lang=" + this.Of.k() + "&title=&type=" + this.Of.m() + "&api_server=" + this.Of.nk().a() + "&static_servers=" + this.Of.nk().b().toString().replace("[", "").replace("]", "") + "&width=100%&timeout=" + this.Of.r() + "&debug=" + this.Of.s() + str2 + str + str3;
        List<String> b2 = this.Of.nk().b();
        String str4 = (b2 != null && b2.size() > 0) ? String.format("https://%s/static/appweb/app3-index.html", b2.get(0)) + this.j : "https://static.geetest.com/static/appweb/app3-index.html" + this.j;
        try {
            GT3GtWebView gT3GtWebView = new GT3GtWebView(this.f1463a.getApplicationContext());
            this.Oi = gT3GtWebView;
            gT3GtWebView.a();
            if (this.Ok != null) {
                d dVar = new d();
                this.Oj = dVar;
                this.Ok.postDelayed(dVar, this.Of.o());
            }
            this.Oi.setObservable(this.Oe);
            this.Oi.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
            this.Oi.setStaticUrl(str4);
            this.Oi.setDataBean(this.Of);
            this.Oi.setMyHandler(this.Ok);
            this.Oi.setRunnable(this.Oj);
            GT3GtWebView gT3GtWebView2 = this.Oi;
            JSHookAop.loadUrl(gT3GtWebView2, str4);
            gT3GtWebView2.loadUrl(str4);
            this.Oi.buildLayer();
            this.Oi.addJavascriptInterface(new b(), "JSInterface");
            this.Oi.setTimeout(this.Of.o());
            d();
        } catch (Exception e) {
            e.printStackTrace();
            h.b(m, "默认webview内核丢失,错误码:204_3-->" + e.toString());
            for (StackTraceElement stackTraceElement : e.getStackTrace()) {
                h.b(m, stackTraceElement.toString());
            }
            Handler handler = this.Ok;
            if (handler != null) {
                try {
                    handler.removeCallbacks(this.Oj);
                    this.Ok.removeMessages(1);
                } catch (Exception unused) {
                }
            }
            ap apVar = this.Oe;
            if (apVar != null) {
                apVar.a("204_3", "webview crate error -->" + e.toString());
            }
        }
        return this.Oi;
    }
}