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


package cn.sealh.wapsdk;

import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.hardware.SensorManager;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.webkit.JavascriptInterface;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import cn.sealh.b.a;
import cn.sealh.d.a;
import cn.sealh.i.a;
import cn.sealh.j.b;
import cn.sealh.wapsdk.bean.BeanCheck;
import cn.sealh.wapsdk.bean.BeanParams;
import cn.sealh.wapsdk.bean.BeanWebStatistic;
import cn.sealh.wapsdk.bean.StatisticState;
import cn.sealh.wapsdk.bean.TaskState;
import cn.sealh.wapsdk.listener.WapRewardListener;
import cn.sealh.wapsdk.listener.WapStatusListener;
import cn.sealh.wapsdk.network.base.utils.NetUtils;
import com.google.gson.Gson;
import com.kuaishou.weapon.p0.i1;
import com.kuaishou.weapon.p0.p0;
import com.umeng.analytics.pro.am;
import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Type;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import okhttp3.Call;

public class WapView extends RelativeLayout {
    public static String F;
    public boolean A;
    public ImageView B;
    public AlertDialog C;
    public String D;
    public boolean E;
    public int a;
    public WapStatusListener b;
    public Context c;
    public final List<cn.sealh.i.a> d;
    public FrameLayout e;
    public ProgressBar f;
    public TextView g;
    public ImageView h;
    public cn.sealh.a.b i;
    public String j;
    public cn.sealh.i.a k;
    public int l;
    public long m;
    public int n;
    public final Set<String> o;
    public String p;
    public int q;
    public final Map<String, TaskState> r;
    public String s;
    public String t;
    public StatisticState u;
    public AlertDialog v;
    public final Set<String> w;
    public final Set<String> x;
    public final Handler y;
    public boolean z;

    public class a implements cn.sealh.e.a {
        public a(WapView wapView) {
        }

        @Override // cn.sealh.e.a
        public void a(int i) {
        }

        @Override // cn.sealh.e.a
        public void a(String str) {
        }
    }

    public class b implements DialogInterface.OnClickListener {
        public final /* synthetic */ String[] a;

        public b(String[] strArr) {
            this.a = strArr;
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            WapView.this.D = this.a[i];
        }
    }

    public class c implements DialogInterface.OnClickListener {
        public c() {
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            if (TextUtils.isEmpty(WapView.this.D)) {
                Toast.makeText(WapView.this.c.getApplicationContext(), "请选择举报类型", 0).show();
                return;
            }
            WapView wapView = WapView.this;
            cn.sealh.i.a aVar = wapView.k;
            if (aVar != null) {
                cn.sealh.c.a.a(aVar, wapView.D, WapManager.getInstance().a);
                Toast.makeText(WapView.this.c.getApplicationContext(), "感谢您的反馈", 0).show();
            }
            WapView.this.C.dismiss();
        }
    }

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

        public void onClick(DialogInterface dialogInterface, int i) {
            WapView.this.C.dismiss();
        }
    }

    public class e implements ValueCallback<String> {
        public final /* synthetic */ cn.sealh.i.a a;
        public final /* synthetic */ int b;

        public e(cn.sealh.i.a aVar, int i) {
            this.a = aVar;
            this.b = i;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // android.webkit.ValueCallback
        public void onReceiveValue(String str) {
            if ("true".equals(str)) {
                return;
            }
            if (this.a.canGoBack()) {
                this.a.goBack();
            } else if (this.b > 1) {
                WapView.this.a((WapView) this.a, (cn.sealh.i.a) true);
            } else {
                WapView.this.E = false;
                ((Activity) WapView.this.c).onBackPressed();
            }
        }
    }

    public class f implements DownloadListener {

        public class a implements b.a {
            public a() {
            }
        }

        public f() {
        }

        public void onDownloadStart(String str, String str2, String str3, String str4, long j) {
            FragmentManager supportFragmentManager;
            cn.sealh.j.b bVar = new cn.sealh.j.b();
            Bundle bundle = new Bundle();
            bundle.putString("url", str);
            bundle.putString("contentDisposition", str3);
            bundle.putString("mimeType", str4);
            bundle.putLong("content_length", j);
            bVar.setArguments(bundle);
            bVar.a = new a();
            Context context = WapView.this.c;
            if ((context instanceof FragmentActivity) && ((FragmentActivity) context).getLifecycle().getCurrentState() == Lifecycle.State.RESUMED && (supportFragmentManager = ((FragmentActivity) WapView.this.c).getSupportFragmentManager()) != null) {
                bVar.show(supportFragmentManager, "DownloadDialog");
            }
        }
    }

    public class g implements a.d {
        public g() {
        }
    }

    public class h {
        public String a;
        public cn.sealh.i.a b;
        public boolean c;

        public class a implements Runnable {
            public final /* synthetic */ boolean a;
            public final /* synthetic */ String b;

            public a(boolean z, String str) {
                this.a = z;
                this.b = str;
            }

            public void run() {
                int i;
                String str;
                Context context;
                if (this.a) {
                    context = WapView.this.getContext().getApplicationContext();
                    str = this.b;
                    i = 1;
                } else {
                    context = WapView.this.getContext().getApplicationContext();
                    str = this.b;
                    i = 0;
                }
                Toast.makeText(context, str, i).show();
            }
        }

        public h(String str, cn.sealh.i.a aVar, boolean z) {
            this.a = str;
            this.b = aVar;
            this.c = z;
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void a(float f, float f2) {
            WapView.a(WapView.this, this.b, f, f2);
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void a(String str) {
            WapView.a(WapView.this, str, true);
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void a(boolean z, String str) {
            cn.sealh.i.a aVar;
            if (z) {
                WapView wapView = WapView.this;
                cn.sealh.i.a aVar2 = wapView.k;
                if (aVar2 != null) {
                    aVar = wapView.a(wapView.c, aVar2.getBeanParams());
                } else {
                    return;
                }
            } else {
                aVar = this.b;
                if (aVar == null) {
                    return;
                }
            }
            aVar.loadUrl(str);
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void b(String str) {
            WapManager instance = WapManager.getInstance();
            Context context = WapView.this.c;
            int webViewId = this.b.getWebViewId();
            WapView wapView = WapView.this;
            instance.a(context, str, true, webViewId, wapView, wapView.a);
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void c(String str) {
            if (this.b != null) {
                if ("default".equals(str)) {
                    str = WapView.F;
                }
                this.b.getSettings().setUserAgentString(str);
            }
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void d(String str) {
            String str2 = this.a;
            cn.sealh.i.a aVar = this.b;
            if (aVar != null) {
                a.C0010a readState = aVar.getReadState();
                if (readState.i.add(str) && !readState.f) {
                    boolean z = true;
                    int i = readState.c + 1;
                    readState.c = i;
                    if (i < readState.d) {
                        z = false;
                    }
                    WapView.this.a((WapView) readState);
                    if (readState.b <= 0 && z && readState.a()) {
                        WapView.a(WapView.this, str2, false);
                    }
                }
            }
        }

        @JavascriptInterface
        public void delCK(String str, String str2) {
            CookieManager instance;
            if (this.c && (instance = CookieManager.getInstance()) != null) {
                Iterator<String> it = cn.sealh.c.a.b(str).iterator();
                while (it.hasNext()) {
                    String next = it.next();
                    if (!TextUtils.isEmpty(next)) {
                        instance.setCookie(next, str2 + "=; Expires=Wed, 31 Dec 2015 23:59:59 GMT");
                    }
                }
            }
        }

        @JavascriptInterface
        public void finishLink() {
            if (this.c) {
                String str = this.a;
                WapView wapView = WapView.this;
                wapView.y.post(new WapView$h$$ExternalSyntheticLambda2(this, str));
            }
        }

        @JavascriptInterface
        public String getDefaultUA() {
            return !this.c ? "" : WapView.F;
        }

        @JavascriptInterface
        public String getFfid() {
            return !this.c ? "" : this.a;
        }

        @JavascriptInterface
        public String getKV(String str) {
            if (!this.c) {
                return "";
            }
            return cn.sealh.c.a.e(WapView.this.c).getString(str, "");
        }

        @JavascriptInterface
        public String getUserID() {
            return !this.c ? "" : WapManager.getInstance().c;
        }

        @JavascriptInterface
        public boolean hasApp(String str) {
            if (!this.c) {
                return false;
            }
            return cn.sealh.c.a.a(WapView.this.c, str);
        }

        @JavascriptInterface
        public String httpGet(String str, String str2) {
            boolean z = false;
            if (str.startsWith("/")) {
                str = NetUtils.getUrl(0) + str;
                z = true;
            }
            cn.sealh.g.a aVar = new cn.sealh.g.a(str);
            if (z) {
                aVar.d.put("token", WapManager.getInstance().a);
            }
            if (TextUtils.isEmpty(str2)) {
                return aVar.a();
            }
            aVar.a(new b(str2));
            return "";
        }

        @JavascriptInterface
        public String httpPost(String str, String str2, String str3) {
            boolean z;
            if (str.startsWith("/")) {
                str = NetUtils.getUrl(0) + str;
                z = true;
            } else {
                z = false;
            }
            cn.sealh.g.b bVar = new cn.sealh.g.b(str);
            if (z) {
                bVar.d.put("token", WapManager.getInstance().a);
            }
            if (!TextUtils.isEmpty(str2)) {
                for (String str4 : str2.split("&")) {
                    String[] split = str4.split("=");
                    bVar.c.put(split[0], split[1]);
                }
            }
            if (TextUtils.isEmpty(str3)) {
                return bVar.a();
            }
            bVar.a(new c(str3));
            return "";
        }

        @JavascriptInterface
        public boolean isFinish() {
            cn.sealh.i.a aVar;
            if (this.c && (aVar = this.b) != null) {
                return aVar.getReadState().f;
            }
            return false;
        }

        /* JADX WARNING: Code restructure failed: missing block: B:75:0x010c, code lost:
            r0 = true;
         */
        /* JADX WARNING: Removed duplicated region for block: B:116:0x01a7  */
        /* JADX WARNING: Removed duplicated region for block: B:132:0x01ee A[ORIG_RETURN, RETURN, SYNTHETIC] */
        /* JADX WARNING: Removed duplicated region for block: B:152:? A[RETURN, SYNTHETIC] */
        /* JADX WARNING: Removed duplicated region for block: B:154:? A[RETURN, SYNTHETIC] */
        /* JADX WARNING: Removed duplicated region for block: B:29:0x006a  */
        /* JADX WARNING: Removed duplicated region for block: B:33:0x0070  */
        /* JADX WARNING: Removed duplicated region for block: B:58:0x00cf  */
        /* JADX WARNING: Removed duplicated region for block: B:61:0x00d4 A[SYNTHETIC, Splitter:B:61:0x00d4] */
        @JavascriptInterface
        public boolean isGoodDevice() {
            boolean z;
            boolean z2;
            boolean z3;
            boolean z4;
            boolean z5;
            boolean z6;
            boolean z7;
            boolean z8;
            boolean z9;
            boolean z10;
            if (!this.c) {
                return false;
            }
            Context context = WapView.this.c;
            int i = 0;
            while (true) {
                String[] strArr = cn.sealh.h.a.a;
                if (i >= strArr.length) {
                    z = false;
                    break;
                } else if (new File(strArr[i]).exists()) {
                    z = true;
                    break;
                } else {
                    i++;
                }
            }
            if (!z) {
                File file = new File("/proc/tty/drivers");
                if (file.exists() && file.canRead()) {
                    byte[] bArr = new byte[1024];
                    try {
                        FileInputStream fileInputStream = new FileInputStream(file);
                        fileInputStream.read(bArr);
                        fileInputStream.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    String str = new String(bArr);
                    String[] strArr2 = cn.sealh.h.a.b;
                    int length = strArr2.length;
                    int i2 = 0;
                    while (true) {
                        if (i2 >= length) {
                            break;
                        } else if (str.indexOf(strArr2[i2]) != -1) {
                            z10 = true;
                            break;
                        } else {
                            i2++;
                        }
                    }
                    if (!z10) {
                        z2 = false;
                        if (!z2) {
                            if (!(((SensorManager) context.getSystemService(am.ac)).getDefaultSensor(5) == null).booleanValue()) {
                                String b2 = cn.sealh.c.a.b();
                                if (!(b2.contains("intel") || b2.contains("amd")) && !cn.sealh.h.a.a()) {
                                    try {
                                        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
                                        while (true) {
                                            if (networkInterfaces.hasMoreElements()) {
                                                if (networkInterfaces.nextElement().getName().equals("eth0")) {
                                                    z9 = true;
                                                    break;
                                                }
                                            } else {
                                                break;
                                            }
                                        }
                                    } catch (SocketException unused) {
                                    }
                                    if (!z9) {
                                        z3 = false;
                                        if (!z3) {
                                            return false;
                                        }
                                        try {
                                            PackageManager packageManager = context.getPackageManager();
                                            if (packageManager != null) {
                                                List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(128);
                                                if (installedApplications.size() != 0) {
                                                    Iterator<ApplicationInfo> it = installedApplications.iterator();
                                                    while (true) {
                                                        if (!it.hasNext()) {
                                                            break;
                                                        }
                                                        ApplicationInfo next = it.next();
                                                        if (!next.packageName.equals("de.robv.android.xposed.installer")) {
                                                            if (next.packageName.equals("com.saurik.substrate")) {
                                                                break;
                                                            }
                                                        } else {
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        } catch (Exception e2) {
                                            e2.printStackTrace();
                                        }
                                        boolean z11 = false;
                                        if (!z11) {
                                            try {
                                                throw new Exception();
                                            } catch (Exception e3) {
                                                StackTraceElement[] stackTrace = e3.getStackTrace();
                                                int length2 = stackTrace.length;
                                                int i3 = 0;
                                                while (true) {
                                                    if (i3 >= length2) {
                                                        z8 = false;
                                                        break;
                                                    }
                                                    StackTraceElement stackTraceElement = stackTrace[i3];
                                                    if (!stackTraceElement.getClassName().equals(p0.b) && (stackTraceElement.getClassName().equals("com.android.internal.os.ZygoteInit") || ((!stackTraceElement.getClassName().equals("com.saurik.substrate.MS$2") || !stackTraceElement.getMethodName().equals("invoked")) && ((!stackTraceElement.getClassName().equals(p0.b) || !stackTraceElement.getMethodName().equals("main")) && (!stackTraceElement.getClassName().equals(p0.b) || !stackTraceElement.getMethodName().equals("handleHookedMethod")))))) {
                                                        i3++;
                                                    }
                                                }
                                                z8 = true;
                                                if (!z8) {
                                                    z4 = false;
                                                }
                                            }
                                        }
                                        z4 = true;
                                        if (z4) {
                                            return false;
                                        }
                                        try {
                                            if (new File("/system/app/Superuser.apk").exists()) {
                                                z5 = true;
                                                if (!z5) {
                                                    String[] strArr3 = {"/system/bin/", "/system/xbin/", "/system/sbin/", "/sbin/", "/vendor/bin/"};
                                                    int i4 = 0;
                                                    while (true) {
                                                        if (i4 >= 5) {
                                                            break;
                                                        }
                                                        try {
                                                            if (new File(strArr3[i4] + i1.w).exists()) {
                                                                z7 = true;
                                                                break;
                                                            }
                                                            i4++;
                                                        } catch (Exception e4) {
                                                            e4.printStackTrace();
                                                        }
                                                    }
                                                    z7 = false;
                                                    if (!z7 && !cn.sealh.c.a.a()) {
                                                        z6 = false;
                                                        if (!z6) {
                                                            return true;
                                                        }
                                                        return false;
                                                    }
                                                }
                                                z6 = true;
                                                if (!z6) {
                                                }
                                            }
                                        } catch (Exception unused2) {
                                        }
                                        z5 = false;
                                        if (!z5) {
                                        }
                                        z6 = true;
                                        if (!z6) {
                                        }
                                    }
                                }
                            }
                        }
                        z3 = true;
                        if (!z3) {
                        }
                    }
                }
                z10 = false;
                if (!z10) {
                }
            }
            z2 = true;
            if (!z2) {
            }
            z3 = true;
            if (!z3) {
            }
            z9 = false;
            if (!z9) {
            }
            z3 = true;
            if (!z3) {
            }
        }

        @JavascriptInterface
        public boolean open(String str, boolean z) {
            if (!this.c) {
                return false;
            }
            WapView wapView = WapView.this;
            wapView.y.post(new WapView$h$$ExternalSyntheticLambda6(this, z, str));
            return true;
        }

        @JavascriptInterface
        public void openWebview(String str) {
            if (this.c) {
                WapView wapView = WapView.this;
                wapView.y.post(new WapView$h$$ExternalSyntheticLambda4(this, str));
            }
        }

        @JavascriptInterface
        public boolean openWith(String str, String str2) {
            if (!this.c) {
                return false;
            }
            return cn.sealh.c.a.a(WapView.this.c, str, str2);
        }

        @JavascriptInterface
        public void setKV(String str, String str2) {
            if (this.c) {
                cn.sealh.c.a.e(WapView.this.c).edit().putString(str, str2).apply();
            }
        }

        @JavascriptInterface
        public void setUA(String str) {
            if (this.c) {
                WapView wapView = WapView.this;
                wapView.y.post(new WapView$h$$ExternalSyntheticLambda3(this, str));
            }
        }

        @JavascriptInterface
        public void showCloseBtn(boolean z) {
            if (this.c) {
                WapView wapView = WapView.this;
                wapView.y.post(new WapView$h$$ExternalSyntheticLambda5(this, z));
            }
        }

        @JavascriptInterface
        public void tapPoint(float f, float f2) {
            WapView wapView;
            cn.sealh.i.a aVar;
            cn.sealh.i.a aVar2;
            if (this.c && (aVar = (wapView = WapView.this).k) != null && (aVar2 = this.b) != null && aVar2 == aVar) {
                wapView.y.post(new WapView$h$$ExternalSyntheticLambda0(this, f, f2));
            }
        }

        @JavascriptInterface
        public void toast(String str, boolean z) {
            if (this.c) {
                WapView wapView = WapView.this;
                wapView.y.post(new a(z, str));
            }
        }

        @JavascriptInterface
        public void visitedPage(String str) {
            if (WapView.this.o.contains(str)) {
                WapView wapView = WapView.this;
                wapView.y.post(new WapView$h$$ExternalSyntheticLambda1(this, str));
            }
        }

        public class b implements cn.sealh.e.a {
            public final /* synthetic */ String a;

            public b(String str) {
                this.a = str;
            }

            @Override // cn.sealh.e.a
            public void a(int i) {
                String str = this.a + "('error')";
                cn.sealh.i.a aVar = h.this.b;
                if (aVar != null) {
                    aVar.evaluateJavascript(str, null);
                }
            }

            @Override // cn.sealh.e.a
            public void a(String str) {
                String str2 = this.a + "('" + str.trim() + "')";
                cn.sealh.i.a aVar = h.this.b;
                if (aVar != null) {
                    aVar.evaluateJavascript(str2, null);
                }
            }
        }

        public class c implements cn.sealh.e.a {
            public final /* synthetic */ String a;

            public c(String str) {
                this.a = str;
            }

            @Override // cn.sealh.e.a
            public void a(int i) {
                String str = this.a + "('error')";
                cn.sealh.i.a aVar = h.this.b;
                if (aVar != null) {
                    aVar.evaluateJavascript(str, null);
                }
            }

            @Override // cn.sealh.e.a
            public void a(String str) {
                String str2 = this.a + "('" + str.trim() + "')";
                cn.sealh.i.a aVar = h.this.b;
                if (aVar != null) {
                    aVar.evaluateJavascript(str2, null);
                }
            }
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void a(boolean z) {
            ImageView imageView;
            cn.sealh.i.a aVar = this.b;
            if (aVar != null) {
                aVar.getReadState().h = z;
            }
            Context context = WapView.this.c;
            if ((context instanceof WapActivity) && (imageView = ((WapActivity) context).b) != null) {
                imageView.setVisibility(z ? 0 : 8);
            }
        }
    }

    public class i extends WebChromeClient {

        public class a implements DialogInterface.OnCancelListener {
            public final /* synthetic */ JsResult a;

            public a(i iVar, JsResult jsResult) {
                this.a = jsResult;
            }

            public void onCancel(DialogInterface dialogInterface) {
                this.a.cancel();
            }
        }

        public class b implements DialogInterface.OnClickListener {
            public final /* synthetic */ JsResult a;

            public b(i iVar, JsResult jsResult) {
                this.a = jsResult;
            }

            public void onClick(DialogInterface dialogInterface, int i) {
                this.a.cancel();
            }
        }

        public class c implements DialogInterface.OnClickListener {
            public final /* synthetic */ JsResult a;

            public c(i iVar, JsResult jsResult) {
                this.a = jsResult;
            }

            public void onClick(DialogInterface dialogInterface, int i) {
                this.a.confirm();
            }
        }

        public class d implements DialogInterface.OnCancelListener {
            public final /* synthetic */ JsPromptResult a;

            public d(i iVar, JsPromptResult jsPromptResult) {
                this.a = jsPromptResult;
            }

            public void onCancel(DialogInterface dialogInterface) {
                this.a.cancel();
            }
        }

        public class e implements DialogInterface.OnClickListener {
            public final /* synthetic */ JsPromptResult a;

            public e(i iVar, JsPromptResult jsPromptResult) {
                this.a = jsPromptResult;
            }

            public void onClick(DialogInterface dialogInterface, int i) {
                this.a.cancel();
            }
        }

        public class f implements DialogInterface.OnClickListener {
            public final /* synthetic */ EditText a;
            public final /* synthetic */ JsPromptResult b;

            public f(i iVar, EditText editText, JsPromptResult jsPromptResult) {
                this.a = editText;
                this.b = jsPromptResult;
            }

            public void onClick(DialogInterface dialogInterface, int i) {
                this.b.confirm(this.a.getText().toString());
            }
        }

        public class g implements DialogInterface.OnClickListener {
            public final /* synthetic */ JsResult a;

            public g(i iVar, JsResult jsResult) {
                this.a = jsResult;
            }

            public void onClick(DialogInterface dialogInterface, int i) {
                this.a.confirm();
            }
        }

        public class h implements DialogInterface.OnCancelListener {
            public final /* synthetic */ JsResult a;

            public h(i iVar, JsResult jsResult) {
                this.a = jsResult;
            }

            public void onCancel(DialogInterface dialogInterface) {
                this.a.cancel();
            }
        }

        public i() {
        }

        public void onCloseWindow(WebView webView) {
            super.onCloseWindow(webView);
            if (WapView.this.d.size() > 1 && (webView instanceof cn.sealh.i.a)) {
                WapView.this.a((cn.sealh.i.a) webView, true);
            }
        }

        public boolean onCreateWindow(WebView webView, boolean z, boolean z2, Message message) {
            WapView wapView = WapView.this;
            if (wapView.k == null) {
                return false;
            }
            ((WebView.WebViewTransport) message.obj).setWebView(wapView.a(webView.getContext(), WapView.this.k.getBeanParams()));
            message.sendToTarget();
            return true;
        }

        public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
            if (!WapView.this.z) {
                jsResult.cancel();
                return true;
            }
            if (Objects.equals(str, webView.getUrl())) {
                AlertDialog.Builder builder = new AlertDialog.Builder(WapView.this.c);
                builder.setTitle("提示");
                builder.setMessage(str2);
                builder.setPositiveButton(17039370, new g(this, jsResult));
                builder.setOnCancelListener(new h(this, jsResult));
                builder.setCancelable(true);
                WapView.this.v = builder.create();
                WapView.this.v.show();
            } else {
                jsResult.cancel();
            }
            return true;
        }

        public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
            new AlertDialog.Builder(WapView.this.c).setTitle("提示").setMessage(str2).setPositiveButton(17039370, new c(this, jsResult)).setNegativeButton(17039360, new b(this, jsResult)).setOnCancelListener(new a(this, jsResult)).create().show();
            return true;
        }

        public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
            View inflate = LayoutInflater.from(webView.getContext()).inflate(R.layout.wapsdk_dialog_prompt, (ViewGroup) null);
            EditText editText = (EditText) inflate.findViewById(R.id.et_msg);
            ((TextView) inflate.findViewById(R.id.tv_message)).setText(str2);
            editText.setText(str3);
            new AlertDialog.Builder(WapView.this.c).setView(inflate).setTitle("提示").setPositiveButton(17039370, new f(this, editText, jsPromptResult)).setNegativeButton(17039360, new e(this, jsPromptResult)).setOnCancelListener(new d(this, jsPromptResult)).create().show();
            return true;
        }

        public void onProgressChanged(WebView webView, int i) {
            String url = webView.getUrl();
            WapView wapView = WapView.this;
            if (webView == wapView.k && url != null && !url.equals(wapView.p)) {
                if (i == 100) {
                    WapView wapView2 = WapView.this;
                    wapView2.p = url;
                    ProgressBar progressBar = wapView2.f;
                    if (progressBar != null) {
                        progressBar.setVisibility(4);
                        return;
                    }
                    return;
                }
                ProgressBar progressBar2 = WapView.this.f;
                if (progressBar2 != null) {
                    progressBar2.setVisibility(0);
                    WapView.this.f.setProgress(i);
                }
            }
        }

        public void onReceivedTitle(WebView webView, String str) {
            super.onReceivedTitle(webView, str);
            if (webView instanceof cn.sealh.i.a) {
                cn.sealh.i.a aVar = (cn.sealh.i.a) webView;
                a.C0010a readState = aVar.getReadState();
                if (readState.j == 0) {
                    readState.k = str;
                }
                WapStatusListener wapStatusListener = WapView.this.b;
                if (wapStatusListener != null) {
                    wapStatusListener.onTitleChanged(aVar.getReadState().k);
                }
            }
        }
    }

    public WapView(Context context) {
        super(context);
        this.d = new ArrayList();
        this.m = System.currentTimeMillis();
        this.n = 1;
        this.o = new HashSet();
        this.p = "";
        this.q = 1;
        this.r = new HashMap();
        HashSet hashSet = new HashSet();
        this.w = hashSet;
        HashSet hashSet2 = new HashSet();
        this.x = hashSet2;
        this.y = new Handler(Looper.getMainLooper());
        this.z = true;
        this.A = false;
        this.D = "";
        this.E = true;
        this.c = context;
        a();
        View inflate = LayoutInflater.from(context).inflate(R.layout.wapsdk_view_wap, (ViewGroup) this, true);
        hashSet2.addAll(WapManager.getInstance().c());
        hashSet.addAll(WapManager.getInstance().b());
        a(inflate);
    }

    public WapView(Context context, BeanParams beanParams, WapStatusListener wapStatusListener) {
        this(context);
        this.a = 1;
        this.b = wapStatusListener;
        a(beanParams);
    }

    public WapView(Context context, String str, WapRewardListener wapRewardListener, WapStatusListener wapStatusListener) {
        this(context, null, str, wapRewardListener, wapStatusListener);
    }

    public WapView(Context context, String str, String str2, WapRewardListener wapRewardListener, WapStatusListener wapStatusListener) {
        this(context);
        this.a = 2;
        this.j = str2;
        this.b = wapStatusListener;
        WapManager.getInstance().a(context, str, wapRewardListener);
    }

    public static /* synthetic */ void a(WapView wapView, String str, boolean z2) {
        cn.sealh.i.a aVar;
        int size = wapView.d.size() - 1;
        while (true) {
            if (size < 0) {
                aVar = null;
                break;
            }
            aVar = wapView.d.get(size);
            if (str.equals(aVar.getReadState().a)) {
                break;
            }
            size--;
        }
        if (aVar != null) {
            a.C0010a readState = aVar.getReadState();
            if ("-1".equals(str)) {
                if (!readState.f) {
                    readState.f = true;
                    cn.sealh.i.a aVar2 = wapView.k;
                    if (aVar2 != null) {
                        if (aVar2.getReadState().a.equals(readState.a)) {
                            Context context = wapView.c;
                            if (context instanceof WapActivity) {
                                ((WapActivity) context).a(readState);
                            }
                            wapView.g.setVisibility(8);
                        }
                        if (wapView.a == 1) {
                            wapView.r.put(str, new TaskState(1, "任务已完成"));
                        } else {
                            WapManager.getInstance().a(200);
                        }
                    } else {
                        return;
                    }
                }
            } else if (!readState.f) {
                cn.sealh.g.b bVar = new cn.sealh.g.b(NetUtils.getUrl(3) + str);
                bVar.d.put("token", WapManager.getInstance().a);
                bVar.a(new cn.sealh.a.d(wapView, readState, z2, str));
            }
            cn.sealh.i.a aVar3 = wapView.k;
            if (aVar3 != null && aVar3.getReadState().a.equals(readState.a)) {
                wapView.g.setVisibility(8);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ boolean a(View view, MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        if (action == 0) {
            ((cn.sealh.a.a) this.i).a();
            this.l++;
            return false;
        } else if (action != 1) {
            return false;
        } else {
            ((cn.sealh.a.a) this.i).a();
            return false;
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void b(View view) {
        b();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void c(View view) {
        cn.sealh.i.a aVar = this.k;
        if (aVar != null) {
            this.p = "";
            aVar.reload();
        }
    }

    public final void a() {
        cn.sealh.b.a.a(new g());
    }

    public final void a(View view) {
        this.e = (FrameLayout) view.findViewById(R.id.fl_web);
        this.f = (ProgressBar) view.findViewById(R.id.web_progressbar);
        this.g = (TextView) view.findViewById(R.id.tips);
        ImageView imageView = (ImageView) findViewById(R.id.iv_tip_off);
        this.B = imageView;
        imageView.setOnClickListener(new WapView$$ExternalSyntheticLambda2(this));
        ImageView imageView2 = (ImageView) view.findViewById(R.id.iv_refresh);
        this.h = imageView2;
        imageView2.setOnClickListener(new WapView$$ExternalSyntheticLambda3(this));
    }

    public final void a(String str) {
        TaskState taskState;
        WapManager instance;
        int i2;
        if (this.a == 1 && (taskState = this.r.get(str)) != null) {
            if (taskState.getState() == 1) {
                WapManager.getInstance().a(200);
                if (!TextUtils.isEmpty(taskState.getMessage())) {
                    Toast.makeText(getContext().getApplicationContext(), taskState.getMessage(), 0).show();
                }
            } else {
                if (taskState.getState() == 2) {
                    instance = WapManager.getInstance();
                    i2 = TypedValues.MotionType.TYPE_QUANTIZE_MOTIONSTEPS;
                } else if (taskState.getState() == 3) {
                    instance = WapManager.getInstance();
                    i2 = TypedValues.MotionType.TYPE_EASING;
                }
                instance.a(i2);
            }
            this.r.remove(str);
        }
    }

    public void a(String str, String str2) {
        a(str, str2, (String) null, (String) null);
    }

    public final void a(boolean z2) {
        FrameLayout frameLayout;
        int i2;
        if (z2) {
            frameLayout = this.e;
            i2 = 4;
        } else {
            this.z = true;
            frameLayout = this.e;
            i2 = 0;
        }
        frameLayout.setVisibility(i2);
    }

    public void b() {
        AlertDialog alertDialog = this.C;
        if (alertDialog == null || !alertDialog.isShowing()) {
            String[] strArr = {"色情低俗", "不实信息", "违法犯罪", "其他"};
            AlertDialog.Builder builder = new AlertDialog.Builder(this.c);
            builder.setTitle("举报类型");
            builder.setSingleChoiceItems(strArr, -1, new b(strArr));
            builder.setPositiveButton("确定", new c());
            builder.setNegativeButton("取消", new d());
            AlertDialog create = builder.create();
            this.C = create;
            this.D = "";
            create.show();
        }
    }

    public void destroyView() {
        onDestroy();
        ViewParent parent = getParent();
        if (parent != null) {
            ((ViewGroup) parent).removeView(this);
        }
        cn.sealh.b.a.a();
    }

    public cn.sealh.i.a getTopWebView() {
        if (this.d.size() <= 0) {
            return null;
        }
        List<cn.sealh.i.a> list = this.d;
        return list.get(list.size() - 1);
    }

    public boolean onBackPressed() {
        if (this.E) {
            this.l++;
            int size = this.d.size();
            if (size <= 0) {
                return false;
            }
            cn.sealh.i.a aVar = this.d.get(size - 1);
            aVar.evaluateJavascript("sdk.onBackPress()", new e(aVar, size));
            return true;
        }
        this.E = true;
        return false;
    }

    public void onDestroy() {
        cn.sealh.i.a aVar = this.k;
        if (aVar != null) {
            a(aVar.getUrl(), (String) null);
        }
        this.b = null;
        WapManager instance = WapManager.getInstance();
        if (instance.j != null) {
            instance.j = null;
            instance.i = true;
        }
        cn.sealh.d.a aVar2 = a.C0009a.a;
        for (int size = aVar2.c.size() - 1; size >= 0; size--) {
            Call call = aVar2.c.get(size);
            if (call != null) {
                call.cancel();
            }
        }
        cn.sealh.a.b bVar = this.i;
        if (bVar != null) {
            ((cn.sealh.a.a) bVar).e.removeCallbacksAndMessages(null);
        }
        for (int size2 = this.d.size() - 1; size2 >= 0; size2--) {
            cn.sealh.i.a aVar3 = this.d.get(size2);
            if (aVar3 != null) {
                a(aVar3, false);
            }
        }
        WapManager.detach();
    }

    public void onPause() {
        cn.sealh.b.a.a();
    }

    public void onResume() {
        cn.sealh.b.a.a(new g());
    }

    public void requestData() {
        if (!this.A) {
            WapManager.getInstance().a(this.c, this.j, this, 2);
        }
    }

    public static /* synthetic */ void b(WapView wapView, WebView webView, String str) {
        Objects.requireNonNull(wapView);
        webView.stopLoading();
        AlertDialog alertDialog = wapView.v;
        if (alertDialog != null && alertDialog.isShowing()) {
            wapView.v.cancel();
        }
        String str2 = WapManager.getInstance().p;
        webView.loadDataWithBaseURL(str2, "<script>location.replace('" + str2 + "')</script>", "text/html", "utf-8", str2);
        if (webView instanceof cn.sealh.i.a) {
            cn.sealh.i.a aVar = (cn.sealh.i.a) webView;
            aVar.setShouldClearHistory(true);
            aVar.setErrorUrl(str);
        }
    }

    public class j extends WebViewClient {

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

            public void run() {
                WapView.this.a((WapView) true);
            }
        }

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

            public void run() {
                WapView.this.a((WapView) false);
            }
        }

        public j() {
        }

        public void doUpdateVisitedHistory(WebView webView, String str, boolean z) {
            super.doUpdateVisitedHistory(webView, str, z);
            if (webView instanceof cn.sealh.i.a) {
                cn.sealh.i.a aVar = (cn.sealh.i.a) webView;
                if (aVar.d && !str.equals(aVar.getErrorUrl())) {
                    aVar.setShouldClearHistory(false);
                    aVar.setErrorUrl("");
                    aVar.clearHistory();
                }
                String js = aVar.getBeanParams().getJs();
                if (!TextUtils.isEmpty(js)) {
                    aVar.evaluateJavascript(js, null);
                }
                WapView.a(WapView.this, aVar.getReadState().a, str);
            }
        }

        public void onPageFinished(WebView webView, String str) {
            super.onPageFinished(webView, str);
            ProgressBar progressBar = WapView.this.f;
            if (progressBar != null) {
                progressBar.setVisibility(4);
            }
            WapView.this.o.add(str);
            webView.evaluateJavascript("setTimeout('sdk && sdk.visitedPage && sdk.visitedPage(location.href)',1000)", null);
        }

        public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
            super.onPageStarted(webView, str, bitmap);
        }

        public void onReceivedError(WebView webView, int i, String str, String str2) {
            super.onReceivedError(webView, i, str, str2);
            if (Build.VERSION.SDK_INT < 23) {
                WapView.a(WapView.this, webView, str2);
            }
        }

        public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
            super.onReceivedError(webView, webResourceRequest, webResourceError);
            if (Build.VERSION.SDK_INT >= 23 && webResourceRequest.isForMainFrame() && webResourceRequest.getUrl() != null) {
                WapView.a(WapView.this, webView, webResourceRequest.getUrl().toString());
            }
        }

        public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
            try {
                if (WapManager.getInstance().r) {
                    sslErrorHandler.cancel();
                    if (webView.getUrl().equals(sslError.getUrl()) || Objects.equals(((cn.sealh.i.a) webView).getReadyUrl(), sslError.getUrl())) {
                        WapView.a(WapView.this, webView, sslError.getUrl());
                        return;
                    }
                    return;
                }
                sslErrorHandler.proceed();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override // android.webkit.WebViewClient
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            boolean z = !str.startsWith("http://") && !str.contains("https://");
            if (z) {
                WapView.a(WapView.this, str);
            } else {
                if (webView instanceof cn.sealh.i.a) {
                    cn.sealh.i.a aVar = (cn.sealh.i.a) webView;
                    aVar.setReadyUrl(str);
                    WapView.a(WapView.this, aVar.getReadState().a, str);
                }
                String host = Uri.parse(str).getHost();
                if (WapView.this.x.contains(host)) {
                    WapView.this.a(false);
                } else if (WapView.this.w.contains(host)) {
                    WapView.b(WapView.this, webView, str);
                    return true;
                } else {
                    a aVar2 = new a();
                    WapView.this.y.postDelayed(aVar2, 50);
                    WapView.this.z = false;
                    b bVar = new b();
                    WapView.this.y.postDelayed(bVar, 1000);
                    cn.sealh.g.b bVar2 = new cn.sealh.g.b(NetUtils.getUrl(7));
                    bVar2.c.put("url", str);
                    bVar2.d.put("token", WapManager.getInstance().a);
                    bVar2.a(new c(aVar2, bVar, webView, str));
                }
            }
            return z;
        }

        public class c implements cn.sealh.e.a {
            public final /* synthetic */ Runnable a;
            public final /* synthetic */ Runnable b;
            public final /* synthetic */ WebView c;
            public final /* synthetic */ String d;

            public c(Runnable runnable, Runnable runnable2, WebView webView, String str) {
                this.a = runnable;
                this.b = runnable2;
                this.c = webView;
                this.d = str;
            }

            @Override // cn.sealh.e.a
            public void a(int i) {
                WapView.this.y.removeCallbacks(this.a);
                WapView.this.y.removeCallbacks(this.b);
                WapView.this.a(false);
            }

            @Override // cn.sealh.e.a
            public void a(String str) {
                BeanCheck beanCheck;
                WapView.this.y.removeCallbacks(this.a);
                WapView.this.y.removeCallbacks(this.b);
                try {
                    beanCheck = (BeanCheck) new Gson().fromJson(str, BeanCheck.class);
                } catch (Exception unused) {
                    beanCheck = null;
                }
                if (beanCheck == null || !beanCheck.isData()) {
                    WapView.this.a(false);
                } else {
                    WapView.b(WapView.this, this.c, this.d);
                }
            }
        }
    }

    public static /* synthetic */ void b(WapView wapView, String str, String str2) {
        cn.sealh.k.a aVar;
        Objects.requireNonNull(wapView);
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            wapView.s = str;
            wapView.t = str2;
            try {
                if (Build.VERSION.SDK_INT >= 23 && wapView.c.checkSelfPermission(com.kuaishou.weapon.p0.h.j) != 0) {
                    Context context = wapView.c;
                    if (context instanceof FragmentActivity) {
                        String[] strArr = {com.kuaishou.weapon.p0.h.j};
                        cn.sealh.a.f fVar = new cn.sealh.a.f(wapView);
                        FragmentManager supportFragmentManager = ((FragmentActivity) context).getSupportFragmentManager();
                        Fragment findFragmentByTag = supportFragmentManager.findFragmentByTag("WapInvisibleFragment");
                        if (findFragmentByTag != null) {
                            aVar = (cn.sealh.k.a) findFragmentByTag;
                        } else {
                            aVar = new cn.sealh.k.a();
                            supportFragmentManager.beginTransaction().add(aVar, "WapInvisibleFragment").commitNow();
                        }
                        aVar.a = fVar;
                        aVar.requestPermissions(strArr, 1);
                        return;
                    }
                }
                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
                request.allowScanningByMediaScanner();
                request.setNotificationVisibility(1);
                request.setAllowedOverMetered(true);
                request.setVisibleInDownloadsUi(true);
                request.setAllowedOverRoaming(true);
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, str2);
                ((DownloadManager) wapView.c.getSystemService("download")).enqueue(request);
            } catch (Exception unused) {
            }
        }
    }

    public final void b(cn.sealh.i.a aVar) {
        BeanParams beanParams = aVar.getBeanParams();
        aVar.setVerticalScrollBarEnabled(false);
        WebSettings settings = aVar.getSettings();
        settings.setAllowFileAccess(true);
        settings.setNeedInitialFocus(false);
        settings.setBuiltInZoomControls(false);
        h hVar = new h(beanParams.getDistributionId(), aVar, beanParams.isEnableJs());
        settings.setJavaScriptEnabled(true);
        aVar.addJavascriptInterface(hVar, "sdk");
        if (beanParams.isNeedMultiWindow()) {
            settings.setSupportMultipleWindows(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
        }
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        if (Build.VERSION.SDK_INT >= 21) {
            settings.setMixedContentMode(0);
        }
        settings.setCacheMode(beanParams.isUseCache() ? -1 : 2);
        settings.setDomStorageEnabled(true);
        settings.setDatabaseEnabled(true);
        settings.setAppCacheEnabled(true);
        settings.setAppCachePath(this.c.getCacheDir().getAbsolutePath() + "/rewardWebCache");
        if (Build.VERSION.SDK_INT >= 21) {
            CookieManager.getInstance().setAcceptThirdPartyCookies(aVar, true);
        }
        aVar.setWebViewClient(new j());
        aVar.setWebChromeClient(new i());
        aVar.setDownloadListener(new f());
        aVar.setOnTouchListener(new WapView$$ExternalSyntheticLambda4(this));
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void b(cn.sealh.i.a aVar, ValueAnimator valueAnimator) {
        aVar.setX((float) ((Integer) valueAnimator.getAnimatedValue()).intValue());
        if (valueAnimator.getAnimatedFraction() == 1.0f) {
            this.e.removeView(aVar);
            aVar.destroy();
            cn.sealh.i.a aVar2 = this.k;
            if (aVar2 != null) {
                String str = aVar2.getReadState().k;
                WapStatusListener wapStatusListener = this.b;
                if (wapStatusListener != null) {
                    wapStatusListener.onTitleChanged(str);
                }
            }
        }
    }

    public final void b(String str, String str2) {
        if (!"-1".equals(str)) {
            cn.sealh.g.b bVar = new cn.sealh.g.b(NetUtils.getUrl(2) + str);
            bVar.h = str2;
            bVar.i = cn.sealh.g.b.j;
            bVar.d.put("token", WapManager.getInstance().a);
            bVar.a(new a(this));
        }
    }

    public static /* synthetic */ void a(WapView wapView, WebView webView, String str) {
        Objects.requireNonNull(wapView);
        String errorUrl = NetUtils.getErrorUrl();
        webView.loadDataWithBaseURL(str, "<!DOCTYPE html><html><head><meta name=\"viewport\" content=\"width=device-width\"/><script>setTimeout(function(){location.replace('" + errorUrl + "')},1e3)</script></head><body>正在加载...</body></html>", "text/html", "utf-8", str);
    }

    public static /* synthetic */ void a(WapView wapView, String str) {
        Objects.requireNonNull(wapView);
        try {
            wapView.c.startActivity(Intent.parseUri(str, 1));
        } catch (Exception unused) {
        }
    }

    public static /* synthetic */ void a(WapView wapView, String str, String str2) {
        Objects.requireNonNull(wapView);
        if (!"-1".equals(str)) {
            StatisticState statisticState = wapView.u;
            if (statisticState == null) {
                wapView.u = new StatisticState(str, str2);
                wapView.a((String) null, str2);
                return;
            }
            String distributionId = statisticState.getDistributionId();
            String url = wapView.u.getUrl();
            if (!str.equals(distributionId) || !str2.equals(url)) {
                wapView.u = new StatisticState(str, str2);
                if (str.equals(distributionId)) {
                    wapView.a(url, str2);
                } else {
                    wapView.a(url, str2, distributionId, str);
                }
            }
        }
    }

    public static /* synthetic */ void a(WapView wapView, View view, float f2, float f3) {
        Objects.requireNonNull(wapView);
        if (view != null) {
            long uptimeMillis = SystemClock.uptimeMillis();
            MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 0, f2, f3, 0);
            long j2 = uptimeMillis + 5;
            MotionEvent obtain2 = MotionEvent.obtain(j2, j2, 1, f2, f3, 0);
            view.onTouchEvent(obtain);
            view.onTouchEvent(obtain2);
            obtain.recycle();
            obtain2.recycle();
        }
    }

    public final void a(cn.sealh.i.a aVar) {
        if (this.k != null) {
            BeanParams beanParams = aVar.getBeanParams();
            a.C0010a readState = this.k.getReadState();
            String str = readState.a;
            this.k = aVar;
            this.e.addView(aVar);
            this.d.add(aVar);
            ValueAnimator ofInt = ValueAnimator.ofInt(Resources.getSystem().getDisplayMetrics().widthPixels, 0);
            ofInt.addUpdateListener(new WapView$$ExternalSyntheticLambda0(aVar));
            ofInt.start();
            if (!str.equals(beanParams.getDistributionId())) {
                a.C0010a aVar2 = new a.C0010a(beanParams.getDistributionId(), beanParams.getTime(), beanParams.getTime(), 0, beanParams.getPiece(), beanParams.isHasReceived(), beanParams.getCloseBtnStrategy(), beanParams.getTitleText());
                aVar.setReadState(aVar2);
                if (!aVar2.f) {
                    if (aVar2.a()) {
                        this.r.put(aVar2.a, new TaskState(2, ""));
                    }
                    ((cn.sealh.a.a) this.i).a(beanParams.getTime());
                    a(aVar2);
                } else {
                    ((cn.sealh.a.a) this.i).a(0);
                    this.g.setVisibility(8);
                }
                Context context = this.c;
                if (context instanceof WapActivity) {
                    ((WapActivity) context).a(aVar2);
                    return;
                }
                return;
            }
            aVar.setReadState(readState);
        }
    }

    public final cn.sealh.i.a a(Context context, BeanParams beanParams) {
        cn.sealh.i.a aVar = new cn.sealh.i.a(context);
        aVar.setWebViewId(this.n);
        this.n++;
        aVar.setBeanParams(beanParams);
        b(aVar);
        a(aVar);
        return aVar;
    }

    public void a(String str, String str2, String str3, String str4) {
        String str5;
        if (this.k != null) {
            long currentTimeMillis = System.currentTimeMillis();
            long j2 = currentTimeMillis - this.m;
            this.m = currentTimeMillis;
            char c2 = (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) ? (TextUtils.isEmpty(str) || !TextUtils.isEmpty(str2)) ? (!TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) ? (char) 0 : 1 : 3 : 2;
            String str6 = TextUtils.isEmpty(str3) ? this.k.getReadState().a : str3;
            int i2 = this.l;
            if (!"-1".equals(str6)) {
                int i3 = this.q + 1;
                Gson gson = new Gson();
                Type type = new cn.sealh.a.g(this).getType();
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date(System.currentTimeMillis()));
                if (c2 == 1) {
                    linkedHashMap.put(String.valueOf(this.q), new BeanWebStatistic(str2, 0, format, 0, "0", "0"));
                    str5 = gson.toJson(linkedHashMap, type);
                } else if (c2 == 2) {
                    if (TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) {
                        BeanWebStatistic beanWebStatistic = new BeanWebStatistic(str, j2, format, i2, "0", "0");
                        BeanWebStatistic beanWebStatistic2 = new BeanWebStatistic(str2, 0, format, 0, "0", "0");
                        linkedHashMap.put(String.valueOf(this.q), beanWebStatistic);
                        linkedHashMap.put(String.valueOf(i3), beanWebStatistic2);
                        b(str6, gson.toJson(linkedHashMap, type));
                    } else {
                        BeanWebStatistic beanWebStatistic3 = new BeanWebStatistic(str, j2, format, i2, "0", "0");
                        BeanWebStatistic beanWebStatistic4 = new BeanWebStatistic(str2, 0, format, 0, "0", str4);
                        linkedHashMap.put(String.valueOf(this.q), beanWebStatistic3);
                        linkedHashMap.put(String.valueOf(i3), beanWebStatistic4);
                        b(str3, gson.toJson(linkedHashMap, type));
                        BeanWebStatistic beanWebStatistic5 = new BeanWebStatistic(str2, 0, format, 0, str3, "0");
                        linkedHashMap.clear();
                        linkedHashMap.put(String.valueOf(i3), beanWebStatistic5);
                        b(str4, gson.toJson(linkedHashMap, type));
                    }
                    this.q++;
                } else if (c2 == 3) {
                    linkedHashMap.put(String.valueOf(this.q), new BeanWebStatistic(str, j2, format, i2, "0", "0"));
                    str5 = gson.toJson(linkedHashMap, type);
                }
                b(str6, str5);
            }
            this.l = 0;
        }
    }

    public void a(String str, boolean z2, int i2) {
        cn.sealh.i.a aVar;
        if (i2 > 0) {
            int size = this.d.size() - 1;
            while (true) {
                if (size < 0) {
                    break;
                }
                aVar = this.d.get(size);
                if (i2 == aVar.getWebViewId()) {
                    break;
                }
                size--;
            }
        }
        aVar = null;
        if (aVar != null) {
            aVar.evaluateJavascript("openWebViewResult(\"" + str + "\"," + z2 + ")", null);
        }
    }

    public void a(BeanParams beanParams) {
        if (!this.A) {
            this.A = true;
            this.h.setVisibility(0);
            if (this.a != 1 && WapManager.getInstance().q) {
                this.B.setVisibility(0);
            } else {
                this.B.setVisibility(4);
            }
            if (beanParams.isHasReceived()) {
                this.i = new cn.sealh.a.e(this, 0);
            } else {
                this.i = new cn.sealh.a.e(this, beanParams.getTime());
                if (beanParams.isTask()) {
                    int time = beanParams.getTime();
                    int piece = beanParams.getPiece();
                    this.g.setVisibility(0);
                    if (time <= 0) {
                        this.g.setText(String.format(Locale.CHINA, "浏览%d篇可获得奖励,%d/%d篇", Integer.valueOf(piece), 0, Integer.valueOf(piece)));
                    } else if (piece <= 0) {
                        this.g.setText(String.format(Locale.CHINA, "继续浏览%d秒可获得奖励", Integer.valueOf(time)));
                    } else {
                        this.g.setText(String.format(Locale.CHINA, "继续浏览%d秒及%d篇可获得奖励,%d/%d篇", Integer.valueOf(time), Integer.valueOf(piece), 0, Integer.valueOf(piece)));
                    }
                }
            }
            cn.sealh.i.a aVar = new cn.sealh.i.a(this.c);
            aVar.setWebViewId(this.n);
            this.n++;
            aVar.setBeanParams(beanParams);
            a.C0010a aVar2 = new a.C0010a(beanParams.getDistributionId(), beanParams.getTime(), beanParams.getTime(), 0, beanParams.getPiece(), beanParams.isHasReceived(), beanParams.getCloseBtnStrategy(), beanParams.getTitleText());
            aVar.setReadState(aVar2);
            Context context = this.c;
            if (context instanceof WapActivity) {
                ((WapActivity) context).a(aVar2);
            }
            if (aVar2.a() && !aVar2.f) {
                this.r.put(aVar2.a, new TaskState(2, ""));
            }
            if (TextUtils.isEmpty(F)) {
                F = aVar.getSettings().getUserAgentString();
            }
            b(aVar);
            this.k = aVar;
            this.e.addView(aVar);
            this.d.add(aVar);
            if (beanParams.isVisitClear()) {
                cn.sealh.c.a.a(beanParams.getWebUrl());
            }
            if (!TextUtils.isEmpty(beanParams.getWebUrl())) {
                aVar.loadDataWithBaseURL(beanParams.getWebUrl(), "<script>location.replace('" + beanParams.getWebUrl() + "')</script>", "text/html", "utf-8", beanParams.getWebUrl());
            }
        }
    }

    public final void a(cn.sealh.i.a aVar, boolean z2) {
        String url = aVar.getUrl();
        String str = aVar.getReadState().a;
        this.d.remove(aVar);
        ValueAnimator ofInt = ValueAnimator.ofInt(0, Resources.getSystem().getDisplayMetrics().widthPixels);
        ofInt.addUpdateListener(new WapView$$ExternalSyntheticLambda1(this, aVar));
        ofInt.start();
        cn.sealh.i.a topWebView = getTopWebView();
        this.k = topWebView;
        if (topWebView != null) {
            String url2 = topWebView.getUrl();
            ProgressBar progressBar = this.f;
            if (progressBar != null) {
                progressBar.setVisibility(4);
            }
            BeanParams beanParams = this.k.getBeanParams();
            a.C0010a readState = this.k.getReadState();
            if (!str.equals(beanParams.getDistributionId())) {
                if (z2) {
                    a(url, url2, str, beanParams.getDistributionId());
                }
                a(str);
                if (!readState.f) {
                    ((cn.sealh.a.a) this.i).a(readState.b);
                    a(readState);
                } else {
                    ((cn.sealh.a.a) this.i).a(0);
                    this.g.setVisibility(8);
                }
                Context context = this.c;
                if (context instanceof WapActivity) {
                    ((WapActivity) context).a(readState);
                }
            } else if (z2) {
                a(url, url2);
            }
        } else {
            a(str);
        }
    }

    public final void a(a.C0010a aVar) {
        int i2 = aVar.d;
        int i3 = aVar.c;
        int i4 = aVar.e;
        int i5 = aVar.b;
        if (i3 > i2) {
            i3 = i2;
        }
        if (i4 > 0) {
            this.g.setVisibility(0);
            if (i2 <= 0) {
                this.g.setText(String.format(Locale.CHINA, "继续浏览%d秒可获得奖励", Integer.valueOf(i5)));
                return;
            }
            this.g.setText(String.format(Locale.CHINA, "继续浏览%d秒及%d篇可获得奖励,%d/%d篇", Integer.valueOf(i5), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i2)));
        } else if (i2 <= 0) {
            this.g.setVisibility(8);
        } else {
            this.g.setVisibility(0);
            this.g.setText(String.format(Locale.CHINA, "浏览%d篇可获得奖励,%d/%d篇", Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i2)));
        }
    }
}