Pinjamwinwin v2.0.7版本的 MD5 值为:254981700b50ce03309ecdaac5d16485

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


package com.pinjam.winwin.ui.activity;

import aa.k;
import aa.l;
import ad.s;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import androidx.lifecycle.o0;
import b6.n7;
import b6.r6;
import b6.v;
import b6.w;
import com.ad.id.face.bean.RecCallback;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.jakewharton.timber.collection.util.HttpTip;
import com.pinjam.winwin.bean.ContactsInfo;
import com.pinjam.winwin.bean.WebResourceBean;
import com.pinjam.winwin.ui.view.PWebView;
import com.pinjamwinwin.R;
import gc.h;
import ha.q;
import hc.g0;
import hc.x;
import java.io.File;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import q9.i;
import sc.h;
public final class WebActivity extends Hilt_WebActivity<k> {
    private long exitIntervalTime;
    private boolean isReceivedError;
    private volatile String jsBackListener;
    private String openSystemChooseContactCallback;
    @SuppressLint({"Range"})
    private final androidx.activity.result.d openSystemChooseContactLauncher;
    private final androidx.activity.result.d protocolActivityLauncher;
    private final androidx.activity.result.d sdkFaceLauncher;
    private final gc.e showService$delegate;
    private final gc.e showToolbar$delegate;
    private final gc.e webUrl$delegate;
    public ia.f webViewModel;
    public static final Companion Companion = new Companion(null);
    private static final String SHOW_TOOLBAR = "showToolbar";
    private static final String SHOW_SERVICE = "showService";
    private static final String WEB_URL = "webUrl";
    private long pageTag = System.currentTimeMillis();
    private final gc.e webView$delegate = gc.f.b(new WebActivity$webView$2(this));

    public static final class Companion {
        private Companion() {
        }

        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final String getSHOW_SERVICE() {
            return WebActivity.SHOW_SERVICE;
        }

        public final String getSHOW_TOOLBAR() {
            return WebActivity.SHOW_TOOLBAR;
        }

        public final String getWEB_URL() {
            return WebActivity.WEB_URL;
        }
    }

    public WebActivity() {
        androidx.activity.result.d registerForActivityResult = registerForActivityResult(new b.e(), new c(1));
        h.e(registerForActivityResult, "registerForActivityResul…e\n            }\n        }");
        this.protocolActivityLauncher = registerForActivityResult;
        androidx.activity.result.d registerForActivityResult2 = registerForActivityResult(new b.d(2), new androidx.activity.result.c(this) {
            public final WebActivity f5651b;

            {
                this.f5651b = this;
            }

            @Override
            public final void a(Object obj) {
                int i3 = r2;
                WebActivity webActivity = this.f5651b;
                switch (i3) {
                    case 0:
                        WebActivity.openSystemChooseContactLauncher$lambda$2(webActivity, (Uri) obj);
                        return;
                    default:
                        WebActivity.sdkFaceLauncher$lambda$4(webActivity, (androidx.activity.result.b) obj);
                        return;
                }
            }
        });
        h.e(registerForActivityResult2, "registerForActivityResul…        }\n        }\n    }");
        this.openSystemChooseContactLauncher = registerForActivityResult2;
        androidx.activity.result.d registerForActivityResult3 = registerForActivityResult(new b.e(), new androidx.activity.result.c(this) {
            public final WebActivity f5651b;

            {
                this.f5651b = this;
            }

            @Override
            public final void a(Object obj) {
                int i3 = r2;
                WebActivity webActivity = this.f5651b;
                switch (i3) {
                    case 0:
                        WebActivity.openSystemChooseContactLauncher$lambda$2(webActivity, (Uri) obj);
                        return;
                    default:
                        WebActivity.sdkFaceLauncher$lambda$4(webActivity, (androidx.activity.result.b) obj);
                        return;
                }
            }
        });
        h.e(registerForActivityResult3, "registerForActivityResul…        }\n        }\n    }");
        this.sdkFaceLauncher = registerForActivityResult3;
        this.showToolbar$delegate = gc.f.b(new WebActivity$showToolbar$2(this));
        this.showService$delegate = gc.f.b(new WebActivity$showService$2(this));
        this.webUrl$delegate = gc.f.b(new WebActivity$webUrl$2(this));
    }

    public static final k access$getDataBinding(WebActivity webActivity) {
        return (k) webActivity.getDataBinding();
    }

    private final boolean getShowService() {
        return ((Boolean) this.showService$delegate.getValue()).booleanValue();
    }

    public final boolean getShowToolbar() {
        return ((Boolean) this.showToolbar$delegate.getValue()).booleanValue();
    }

    private final String getWebUrl() {
        return (String) this.webUrl$delegate.getValue();
    }

    public final PWebView getWebView() {
        return (PWebView) this.webView$delegate.getValue();
    }

    private final void handlePhoto(int i3, Intent intent) {
        String str = i3 != 4133 ? i3 != 4134 ? "cameraFaceResult" : "cameraShooting" : "resultShooting";
        if (h.a(str, "cameraShooting") && intent == null) {
            loadJS(str, "-2", HttpTip.defaultEmpty, "canceled", HttpTip.defaultEmpty);
        } else if (intent == null) {
            loadJS(str, HttpTip.defaultCode, HttpTip.defaultEmpty, "canceled", HttpTip.defaultEmpty);
        } else {
            Serializable serializableExtra = intent.getSerializableExtra("face_identify_result");
            h.d(serializableExtra, "null cannot be cast to non-null type com.ad.id.face.bean.RecCallback");
            RecCallback recCallback = (RecCallback) serializableExtra;
            if (!h.a(recCallback.getS(), "0")) {
                loadJS(str, recCallback.getS(), HttpTip.defaultEmpty, recCallback.getM(), HttpTip.defaultEmpty);
                return;
            }
            File file = new File(recCallback.getP());
            gc.e eVar = p9.d.f11251a;
            p9.d.c(file, str, new WebActivity$handlePhoto$1$1(this, str, recCallback, file));
        }
    }

    private final void loadWeb() {
        k kVar = (k) getDataBinding();
        registWebStatus();
        if (!getShowToolbar()) {
            showLoading();
        }
        Log.d("WEB_URL", getWebUrl());
        PWebView pWebView = kVar.f819r;
        String webUrl = getWebUrl();
        h.e(webUrl, "webUrl");
        pWebView.loadUrl(webUrl);
    }

    public static final void openSystemChooseContactLauncher$lambda$2(WebActivity webActivity, Uri uri) {
        h.f(webActivity, "this$0");
        if (uri != null) {
            Cursor query = webActivity.getContentResolver().query(uri, new String[]{"data1", "display_name"}, null, null, null);
            if (query == null || !query.moveToFirst()) {
                return;
            }
            String string = query.getString(query.getColumnIndex("data1"));
            String string2 = query.getString(query.getColumnIndex("display_name"));
            h.e(string2, "displayName");
            h.e(string, "mobileNo");
            String b10 = w.b(new ContactsInfo(string2, string));
            String str = webActivity.openSystemChooseContactCallback;
            if (str != null) {
                webActivity.loadJS(str, b10);
            }
            i.b("chooseContacts_end");
        }
    }

    private final void registWebStatus() {
        k kVar = (k) getDataBinding();
        PWebView pWebView = kVar.f819r;
        WebActivity$registWebStatus$1$1 webActivity$registWebStatus$1$1 = new WebActivity$registWebStatus$1$1(kVar, this);
        WebActivity$registWebStatus$1$2 webActivity$registWebStatus$1$2 = new WebActivity$registWebStatus$1$2(this);
        WebActivity$registWebStatus$1$3 webActivity$registWebStatus$1$3 = new WebActivity$registWebStatus$1$3(this);
        WebActivity$registWebStatus$1$4 webActivity$registWebStatus$1$4 = new WebActivity$registWebStatus$1$4(this);
        WebActivity$registWebStatus$1$5 webActivity$registWebStatus$1$5 = new WebActivity$registWebStatus$1$5(kVar, this);
        pWebView.getClass();
        pWebView.f5656d = webActivity$registWebStatus$1$1;
        pWebView.f5660j = webActivity$registWebStatus$1$2;
        pWebView.f5661m = webActivity$registWebStatus$1$3;
        pWebView.f5662p = webActivity$registWebStatus$1$4;
        pWebView.f5663s = webActivity$registWebStatus$1$5;
    }

    private final void registerJsMonitor() {
        Object a10;
        try {
            h.a aVar = gc.h.f7568a;
            getWebView().addJavascriptInterface(new ka.b(this) {
                {
                    super(this);
                }

                @Override
                public void handleError(String str) {
                    PWebView webView;
                    sc.h.f(str, "message");
                    Pair[] pairArr = new Pair[2];
                    pairArr[0] = new Pair("errorMsg", str);
                    webView = this.getWebView();
                    String url = webView.getUrl();
                    if (url == null) {
                        url = HttpTip.defaultEmpty;
                    }
                    pairArr[1] = new Pair("url", url);
                    LinkedHashMap e10 = g0.e(pairArr);
                    LinkedList linkedList = i.f11807a;
                    i.a("onReceiveError", e10);
                }

                @Override
                public void handleResource(String str) {
                    JsonElement parse;
                    boolean z8;
                    PWebView webView;
                    String url;
                    Object fromJson;
                    String json;
                    sc.h.f(str, "jsonStr");
                    v.a("handleResource : ".concat(str));
                    Gson gson = q9.b.f11797a;
                    if (!TextUtils.isEmpty(str)) {
                        try {
                            JsonParser jsonParser = q9.b.f11798b;
                            sc.h.c(jsonParser);
                            parse = jsonParser.parse(str);
                        } catch (Exception e10) {
                            sc.h.f("GsonUtils#isJsonObject = false ,exception:" + e10.getMessage(), "msg");
                        }
                        if (parse != null) {
                            if (parse.isJsonObject()) {
                                z8 = true;
                                if (!z8) {
                                    if (!TextUtils.isEmpty(str)) {
                                        try {
                                            JsonParser jsonParser2 = q9.b.f11798b;
                                            sc.h.c(jsonParser2);
                                            JsonElement parse2 = jsonParser2.parse(str);
                                            if (parse2 != null) {
                                                if (parse2.isJsonArray()) {
                                                    z8 = true;
                                                }
                                            }
                                        } catch (Exception e11) {
                                            sc.h.f("GsonUtils#isJsonArray = false ,exception:" + e11.getMessage(), "msg");
                                        }
                                    }
                                    z8 = false;
                                }
                                if (z8) {
                                    Gson gson2 = q9.b.f11797a;
                                    Type type = new TypeToken<List<? extends WebResourceBean>>() {
                                    }.getType();
                                    synchronized (q9.b.class) {
                                        Gson gson3 = q9.b.f11797a;
                                        sc.h.c(gson3);
                                        fromJson = gson3.fromJson(str, type);
                                    }
                                    List list = (List) fromJson;
                                    q qVar = new q() {
                                        @Override
                                        public boolean test(WebResourceBean webResourceBean) {
                                            sc.h.f(webResourceBean, "element");
                                            webResourceBean.setName(s.i(webResourceBean.getName(), "https://api.pinjamwinwin.com/ina/", HttpTip.defaultEmpty));
                                            Uri parse3 = Uri.parse("https://web.pinjamwinwin.com/m/#/");
                                            String scheme = parse3.getScheme();
                                            String host = parse3.getHost();
                                            webResourceBean.setName(s.i(webResourceBean.getName(), scheme + "://" + host, HttpTip.defaultEmpty));
                                            return (TextUtils.equals(webResourceBean.getInitiatorType(), "script") || TextUtils.equals(webResourceBean.getInitiatorType(), "img")) && !(TextUtils.equals(webResourceBean.getDuration(), "0") && TextUtils.equals(webResourceBean.getTransferSize(), "0"));
                                        }
                                    };
                                    sc.h.f(list, "array");
                                    ArrayList arrayList = new ArrayList();
                                    for (Object obj : list) {
                                        if (qVar.test(obj)) {
                                            arrayList.add(obj);
                                        }
                                    }
                                    Gson gson4 = q9.b.f11797a;
                                    synchronized (q9.b.class) {
                                        Gson gson5 = q9.b.f11797a;
                                        sc.h.c(gson5);
                                        json = gson5.toJson(arrayList);
                                        sc.h.e(json, "gson!!.toJson(list)");
                                    }
                                    str = json;
                                }
                                Pair[] pairArr = new Pair[3];
                                webView = this.getWebView();
                                url = webView.getUrl();
                                if (url == null) {
                                    url = HttpTip.defaultEmpty;
                                }
                                pairArr[0] = new Pair("url", url);
                                pairArr[1] = new Pair("resourceList", str);
                                pairArr[2] = new Pair("totalTime", Long.valueOf(getEndTime() - getStartTime()));
                                LinkedHashMap e12 = g0.e(pairArr);
                                LinkedList linkedList = i.f11807a;
                                i.a("onLoadResource", e12);
                            }
                        }
                    }
                    z8 = false;
                    if (!z8) {
                    }
                    if (z8) {
                    }
                    Pair[] pairArr2 = new Pair[3];
                    webView = this.getWebView();
                    url = webView.getUrl();
                    if (url == null) {
                    }
                    pairArr2[0] = new Pair("url", url);
                    pairArr2[1] = new Pair("resourceList", str);
                    pairArr2[2] = new Pair("totalTime", Long.valueOf(getEndTime() - getStartTime()));
                    LinkedHashMap e122 = g0.e(pairArr2);
                    LinkedList linkedList2 = i.f11807a;
                    i.a("onLoadResource", e122);
                }
            }, ka.b.JS_BRIDGE_NAME);
            a10 = Unit.f9119a;
        } catch (Throwable th) {
            h.a aVar2 = gc.h.f7568a;
            a10 = n7.a(th);
        }
        if (gc.h.a(a10) != null) {
            i.b("handleResource_error");
        }
    }

    public static final void sdkFaceLauncher$lambda$4(WebActivity webActivity, androidx.activity.result.b bVar) {
        int i3;
        sc.h.f(webActivity, "this$0");
        Intent intent = bVar.f982b;
        if (intent != null) {
            Serializable serializableExtra = intent.getSerializableExtra("Smart.Living.Result");
            sc.h.d(serializableExtra, "null cannot be cast to non-null type zz.ii.ll.ac.SmartLiving.Result");
            ae.a aVar = (ae.a) serializableExtra;
            v.a("Living Face Resule === ".concat(w.b(aVar)));
            int i10 = oe.b.f11113c;
            if (i10 != 0) {
                i3 = i10;
            } else if (!aVar.f919a) {
                i3 = 2;
            } else {
                i3 = 0;
            }
            if (i3 == 1) {
                String str = oe.b.f11112b;
                sc.h.e(str, "smartLivingResult.livingId");
                String str2 = oe.b.f11116f;
                sc.h.e(str2, "smartLivingResult.imageUrl");
                webActivity.loadJS("resultNativeFaceSuccess", str, str2);
                return;
            }
            String[] strArr = new String[2];
            if (i10 == 0) {
                if (!aVar.f919a) {
                    i10 = 2;
                } else {
                    i10 = 0;
                }
            }
            strArr[0] = String.valueOf(a3.a.b(i10));
            String str3 = oe.b.f11114d;
            if (str3 == null) {
                if (!aVar.f919a) {
                    str3 = "unknown";
                } else {
                    str3 = null;
                }
            }
            if (str3 == null) {
                str3 = HttpTip.defaultEmpty;
            }
            strArr[1] = str3;
            webActivity.loadJS("resultNativeFaceFailure", strArr);
        }
    }

    public final androidx.activity.result.d getSdkFaceLauncher() {
        return this.sdkFaceLauncher;
    }

    public final ia.f getWebViewModel() {
        ia.f fVar = this.webViewModel;
        if (fVar != null) {
            return fVar;
        }
        sc.h.m("webViewModel");
        throw null;
    }

    @Override
    public void initView() {
        ArrayList arrayList = ha.b.f8125a;
        ha.b.f8125a.add(Long.valueOf(this.pageTag));
        showOrHideService(getShowService());
        l lVar = (l) ((k) getDataBinding());
        lVar.f821t = Boolean.valueOf(getShowToolbar());
        synchronized (lVar) {
            lVar.f826w |= 4;
        }
        lVar.a(1);
        lVar.m();
        l lVar2 = (l) ((k) getDataBinding());
        lVar2.f820s = getWebViewModel();
        synchronized (lVar2) {
            lVar2.f826w |= 2;
        }
        lVar2.a(2);
        lVar2.m();
        b6.g0.e(com.bumptech.glide.d.b(this), null, new WebActivity$initView$1(this, null), 3);
        ((ia.b) x9.l.f15312a.getValue()).f8375d.e(this, new WebActivity$sam$androidx_lifecycle_Observer$0(new WebActivity$initView$2(this)));
        getWebViewModel().f8385g.e(this, new WebActivity$sam$androidx_lifecycle_Observer$0(new WebActivity$initView$3(this)));
        loadWeb();
        registerJsMonitor();
    }

    public final void loadJS(String str, String... strArr) {
        sc.h.f(str, "method");
        sc.h.f(strArr, "params");
        getWebView().a(str, (String[]) Arrays.copyOf(strArr, strArr.length));
    }

    @Override
    public void onActivityResult(int i3, int i10, Intent intent) {
        super.onActivityResult(i3, i10, intent);
        if (i10 == -1) {
            if (i3 == 4131 || i3 == 4133 || i3 == 4134) {
                handlePhoto(i3, intent);
            }
        } else if (i10 != 0) {
        } else {
            if (i3 == 4131 || i3 == 4133 || i3 == 4134) {
                handlePhoto(i3, null);
            }
        }
    }

    @Override
    public void onBackPressed() {
        long j10;
        long j11 = this.pageTag;
        ArrayList arrayList = ha.b.f8125a;
        Long l10 = (Long) x.m(ha.b.f8125a);
        if (l10 != null) {
            j10 = l10.longValue();
        } else {
            j10 = -1;
        }
        if (j11 == j10) {
            if (!getWebView().canGoBack()) {
                if (System.currentTimeMillis() - this.exitIntervalTime > 2000) {
                    this.exitIntervalTime = System.currentTimeMillis();
                    r6.l(getString(R.string.f17840d2));
                    return;
                }
                getOnBackPressedDispatcher().b();
                return;
            }
            getWebView().goBack();
            return;
        }
        String str = this.jsBackListener;
        if (str != null) {
            loadJS(str, new String[0]);
        }
    }

    public final void openSystemChooseContact(String str) {
        sc.h.f(str, "callback");
        this.openSystemChooseContactCallback = str;
        this.openSystemChooseContactLauncher.a(null);
    }

    public final void setOnJsBackListener(String str) {
        this.jsBackListener = str;
    }

    public final void setTitle(String str) {
        o0 o0Var = getWebViewModel().f8374d;
        if (str == null) {
            str = HttpTip.defaultEmpty;
        }
        o0Var.j(str);
    }

    public final void setWebViewModel(ia.f fVar) {
        sc.h.f(fVar, "<set-?>");
        this.webViewModel = fVar;
    }

    public final void showOrHideService(boolean z8) {
        getWebViewModel().f8384f.j(Boolean.valueOf(z8));
    }
}