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


package com.kwad.components.core.webview.kwai;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebView;
import com.czhj.sdk.common.Constants;
import com.kwad.components.core.c.a.d;
import com.kwad.components.core.webview.KsAdWebView;
import com.kwad.components.kwai.b.b;
import com.kwad.sdk.core.report.w;
import com.kwad.sdk.core.response.model.AdTemplate;

public final class c extends a {
    private long NN;
    private boolean NT;
    private a jb;

    public static class a {
        private boolean NQ;
        private boolean NS = true;
        private KsAdWebView.b NU;
        private w.b NV;
        private boolean NW = true;
        private KsAdWebView.c NX;
        private boolean NY = true;
        private AdTemplate mAdTemplate;
        private final Context mContext;
        private KsAdWebView.d sV;

        public a(Context context) {
            this.mContext = context;
        }

        public final a R(AdTemplate adTemplate) {
            this.mAdTemplate = adTemplate;
            return this;
        }

        public final a a(KsAdWebView.b bVar) {
            this.NU = bVar;
            return this;
        }

        public final a a(KsAdWebView.c cVar) {
            this.NX = cVar;
            return this;
        }

        public final a aB(boolean z) {
            this.NY = z;
            return this;
        }

        public final a aC(boolean z) {
            this.NW = z;
            return this;
        }

        public final a aD(boolean z) {
            this.NQ = true;
            return this;
        }

        public final a b(KsAdWebView.d dVar) {
            this.sV = dVar;
            return this;
        }

        public final a b(w.b bVar) {
            this.NV = bVar;
            return this;
        }

        public final AdTemplate getAdTemplate() {
            return this.mAdTemplate;
        }

        public final w.b getClientParams() {
            return this.NV;
        }

        public final Context getContext() {
            return this.mContext;
        }

        public final KsAdWebView.c getOnWebViewScrollChangeListener() {
            return this.NX;
        }

        public final KsAdWebView.d getWebListener() {
            return this.sV;
        }

        public final KsAdWebView.b ln() {
            return this.NU;
        }

        public final boolean pC() {
            return this.NY;
        }

        public final boolean pD() {
            return this.NS;
        }

        public final boolean pE() {
            return this.NW;
        }

        public final boolean pF() {
            return this.NQ;
        }
    }

    public final void aH(String str) {
        this.mUniqueId = str;
    }

    public final a getClientConfig() {
        return this.jb;
    }

    public final void onPageFinished(WebView webView, String str) {
        super.onPageFinished(webView, str);
        b.x(this.mUniqueId, "onPageFinished");
        a aVar = this.jb;
        if (aVar != null && aVar.pF() && !this.NT) {
            this.NT = true;
            if (this.NN > 0) {
                if (this.jb.getClientParams() == null) {
                    this.jb.b(new w.b());
                }
                this.jb.getClientParams().baz = System.currentTimeMillis() - this.NN;
                this.NN = -1;
            }
            com.kwad.sdk.core.report.a.c(this.jb.getAdTemplate(), this.jb.getClientParams());
        }
        a aVar2 = this.jb;
        if (aVar2 != null && aVar2.getWebListener() != null) {
            this.jb.getWebListener().ah();
        }
    }

    public final void onPageStarted(WebView webView, String str, Bitmap bitmap) {
        super.onPageStarted(webView, str, bitmap);
        b.x(this.mUniqueId, "onPageStart");
        a aVar = this.jb;
        if (aVar != null && aVar.getWebListener() != null) {
            this.jb.getWebListener().ag();
        }
    }

    public final void onReceivedError(WebView webView, int i, String str, String str2) {
        super.onReceivedError(webView, i, str, str2);
        com.kwad.sdk.core.e.b.d("KsAdWebViewClient", "onReceivedError " + i);
        a aVar = this.jb;
        if (!(aVar == null || aVar.getWebListener() == null)) {
            this.jb.getWebListener().b(i, str, str2);
        }
        b.z(str2, str);
        a aVar2 = this.jb;
        if (aVar2 != null && aVar2.pF()) {
            com.kwad.sdk.core.report.a.e(this.jb.getAdTemplate(), this.jb.getClientParams());
        }
    }

    public final boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
        return (Build.VERSION.SDK_INT >= 26 && renderProcessGoneDetail != null && renderProcessGoneDetail.didCrash()) || super.onRenderProcessGone(webView, renderProcessGoneDetail);
    }

    public final void r(long j) {
        this.NN = j;
    }

    public final void setClientConfig(a aVar) {
        this.jb = aVar;
        setNeedHybridLoad(aVar.pD());
    }

    @Override // android.webkit.WebViewClient
    public final boolean shouldOverrideUrlLoading(WebView webView, String str) {
        com.kwad.sdk.core.e.b.e("KsAdWebViewClient", "shouldOverrideUrlLoading url=" + str);
        b.x(this.mUniqueId, "shouldOverrideUrlLoading");
        try {
            if (!str.startsWith(Constants.HTTP)) {
                if (!str.startsWith(Constants.HTTPS)) {
                    if (!str.startsWith(com.tencent.smtt.sdk.WebView.SCHEME_TEL)) {
                        if (!str.startsWith("sms:")) {
                            a aVar = this.jb;
                            if (aVar != null && aVar.pC()) {
                                int J = d.J(this.jb.getContext(), str);
                                if (J == 1) {
                                    if (this.jb.ln() != null) {
                                        this.jb.ln().onSuccess();
                                    }
                                    com.kwad.sdk.core.report.a.k(this.jb.getAdTemplate(), 2);
                                    return true;
                                }
                                if (this.jb.ln() != null) {
                                    this.jb.ln().onFailed();
                                }
                                if (J == -1) {
                                    com.kwad.sdk.core.report.a.l(this.jb.getAdTemplate(), 2);
                                }
                            }
                            return true;
                        }
                    }
                    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
                    a aVar2 = this.jb;
                    if (aVar2 != null) {
                        aVar2.getContext().startActivity(intent);
                    }
                    return true;
                }
            }
            return super.shouldOverrideUrlLoading(webView, str);
        } catch (Exception e) {
            com.kwad.sdk.core.e.b.printStackTrace(e);
        }
    }
}