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


package com.iBookStar.activityComm;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.RelativeSizeSpan;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.baidu.idl.face.platform.utils.BitmapUtils;
import com.bytedance.sdk.openadsdk.BuildConfig;
import com.iBookStar.R;
import com.iBookStar.utils.l;
import com.iBookStar.views.CommonWebView;
import com.iBookStar.views.NativeAdUtil;
import com.iBookStar.views.PopupWebView;
import com.iBookStar.views.SdkAdMonitorView;
import com.iBookStar.views.SkinProgressBar;
import com.iBookStar.views.TaskProgressBar;
import com.iBookStar.views.YmConfig;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode;
import com.sigmob.sdk.base.mta.PointCategory;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import org.json.JSONArray;
import org.json.JSONObject;

public class CoinWebViewFragment extends Fragment implements CommonWebView.g2 {
    private static Stack<CoinWebViewFragment> n0 = new Stack<>();
    private static boolean o0 = false;
    private boolean A = false;
    private int B = 0;
    private float C;
    private float D;
    private int E = 0;
    private boolean F = false;
    private boolean G = false;
    private boolean H = false;
    private com.iBookStar.a.f I;
    private String J = "";

    /* renamed from: K  reason: collision with root package name */
    private int f102K;
    private List<String> L = new ArrayList();
    private boolean M = false;
    private String N;
    private boolean O = false;
    private boolean P = false;
    private boolean Q = false;
    private boolean R = false;
    private boolean S = false;
    private int T = 0;
    private String U;
    private boolean V = false;
    private Map<String, PopupWebView> W = new HashMap();
    private long X;
    private boolean Y;
    private boolean Z = false;
    protected Activity a;
    private boolean a0 = false;
    protected RelativeLayout b;
    private String b0;
    protected CommonWebView c;
    private boolean c0;
    protected SkinProgressBar d;
    private boolean d0 = false;
    protected TaskProgressBar e;
    private String e0;
    protected int f = 100;
    private String f0;
    protected String g;
    private String g0;
    protected String h;
    private String h0;
    protected String i;
    private boolean i0 = false;
    protected boolean j = false;
    private boolean j0 = false;
    protected y k;
    private boolean k0 = false;
    protected boolean l = false;
    private boolean l0 = false;
    protected boolean m = false;
    private Set<String> m0 = new HashSet();
    protected boolean n = false;
    protected boolean o = false;
    protected boolean p = false;
    private Intent q = new Intent();
    private boolean r = false;
    private String s;
    private com.iBookStar.a.g t;
    private com.iBookStar.a.g u;
    private int v;
    private int w;
    private int x;
    private int y = 10;
    private float z = 0.0f;

    class a implements Runnable {
        a() {
        }

        public void run() {
            CoinWebViewFragment.this.x();
        }
    }

    /* access modifiers changed from: package-private */
    public class b implements TaskProgressBar.j {
        b() {
        }

        @Override // com.iBookStar.views.TaskProgressBar.j
        public void a() {
            if (!CoinWebViewFragment.this.O) {
                if (CoinWebViewFragment.this.E == 1) {
                    if (!CoinWebViewFragment.this.S) {
                        com.iBookStar.utils.v.a(CoinWebViewFragment.this.R);
                    } else {
                        CoinWebViewFragment.this.q.putExtra("opennext", true);
                    }
                    CoinWebViewFragment.this.a(true, false);
                } else if (CoinWebViewFragment.this.E == 2) {
                    CoinWebViewFragment.this.G = true;
                    CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                    coinWebViewFragment.a((CoinWebViewFragment) coinWebViewFragment.u, (com.iBookStar.a.g) 1);
                }
            }
        }

        @Override // com.iBookStar.views.TaskProgressBar.j
        public void b() {
            if (!CoinWebViewFragment.this.O) {
                if (CoinWebViewFragment.this.E == 1) {
                    if (!CoinWebViewFragment.this.S) {
                        com.iBookStar.utils.v.a(CoinWebViewFragment.this.R);
                    } else {
                        CoinWebViewFragment.this.q.putExtra("opennext", true);
                    }
                    CoinWebViewFragment.this.a(true, false);
                } else if (CoinWebViewFragment.this.E == 2) {
                    CoinWebViewFragment.this.G = true;
                    CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                    coinWebViewFragment.a((CoinWebViewFragment) coinWebViewFragment.u, (com.iBookStar.a.g) 1);
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class c extends CommonWebView.f2 {
        c() {
        }

        @Override // com.iBookStar.views.CommonWebView.f2
        public void a(CommonWebView commonWebView, String str) {
            com.iBookStar.utils.p.a("CoinWebViewFragment", "ttttttttttttttt, onPageFinished=" + str);
            CoinWebViewFragment.this.a((CoinWebViewFragment) commonWebView, (CommonWebView) str, (String) 2);
            CoinWebViewFragment.this.d.setVisibility(8);
            super.a(commonWebView, str);
        }

        @Override // com.iBookStar.views.CommonWebView.f2
        public void a(CommonWebView commonWebView, String str, Bitmap bitmap) {
            com.iBookStar.utils.p.a("CoinWebViewFragment", "ttttttttttttttt, onPageStarted=" + str);
            CoinWebViewFragment.this.a((CoinWebViewFragment) commonWebView, (CommonWebView) str, (String) 1);
            CoinWebViewFragment.this.d.setVisibility(0);
            super.a(commonWebView, str, bitmap);
        }

        @Override // com.iBookStar.views.CommonWebView.f2
        public boolean b(CommonWebView commonWebView, String str) {
            com.iBookStar.utils.p.a("CoinWebViewFragment", "tttttttttttttttt, shouldOverrideUrlLoading=" + str);
            if (CoinWebViewFragment.this.a(commonWebView, str)) {
                return true;
            }
            CoinWebViewFragment.this.c.report2Web();
            if (CoinWebViewFragment.this.v > 0 && CoinWebViewFragment.this.i0 && "buy".equalsIgnoreCase(CoinWebViewFragment.this.J) && !str.startsWith("http://") && !str.startsWith("https://")) {
                try {
                    Intent intent = new Intent("android.intent.action.VIEW");
                    intent.setData(Uri.parse(str));
                    intent.addFlags(268435456);
                    CoinWebViewFragment.this.a.startActivity(intent);
                    if (!CoinWebViewFragment.this.j0 || CoinWebViewFragment.this.m0.size() < 2) {
                        CoinWebViewFragment.this.j0 = true;
                        CoinWebViewFragment.this.m0.add(str);
                        CoinWebViewFragment.this.d((CoinWebViewFragment) false);
                        com.iBookStar.a.d.a().c(CoinWebViewFragment.this.I);
                    }
                    return true;
                } catch (Exception unused) {
                }
            }
            return super.b(commonWebView, str);
        }
    }

    /* access modifiers changed from: package-private */
    public class d extends CommonWebView.d2 {
        d() {
        }

        @Override // com.iBookStar.views.CommonWebView.d2
        public void a(CommonWebView commonWebView, int i) {
            CoinWebViewFragment.this.d.setProgress(i);
            super.a(commonWebView, i);
        }

        @Override // com.iBookStar.views.CommonWebView.d2
        public void a(CommonWebView commonWebView, String str) {
            if (com.iBookStar.utils.s.c(str)) {
                CoinWebViewFragment.this.g = str;
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class e implements View.OnTouchListener {
        e() {
        }

        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (CoinWebViewFragment.this.F) {
                return true;
            }
            int action = motionEvent.getAction();
            if (action == 0) {
                CoinWebViewFragment.this.C = motionEvent.getY();
            } else if (action == 1) {
                CoinWebViewFragment.this.D = motionEvent.getY();
                if (CoinWebViewFragment.this.E == 0 && CoinWebViewFragment.this.e.isShow()) {
                    float abs = Math.abs(CoinWebViewFragment.this.D - CoinWebViewFragment.this.C);
                    if (!CoinWebViewFragment.this.d0 && CoinWebViewFragment.this.j0 && abs > 50.0f) {
                        CoinWebViewFragment.this.c((CoinWebViewFragment) false);
                    }
                }
            }
            return false;
        }
    }

    /* access modifiers changed from: package-private */
    public class f implements Runnable {
        final /* synthetic */ int a;
        final /* synthetic */ String b;
        final /* synthetic */ CommonWebView c;

        f(int i, String str, CommonWebView commonWebView) {
            this.a = i;
            this.b = str;
            this.c = commonWebView;
        }

        public void run() {
            if (!CoinWebViewFragment.this.a.isFinishing()) {
                if (CoinWebViewFragment.this.E == 0 && com.iBookStar.utils.s.c(CoinWebViewFragment.this.s)) {
                    int i = 2;
                    com.iBookStar.utils.p.a("CoinWebViewFragment", String.format("ttttttttttttttt--1, loc=%d, url=%s", Integer.valueOf(this.a), this.b));
                    String c2 = com.iBookStar.utils.k.c(this.b);
                    if (!CoinWebViewFragment.this.s.equalsIgnoreCase(c2)) {
                        com.iBookStar.utils.p.a("CoinWebViewFragment", String.format("ttttttttttttttt--2, loc=%d, url=%s", Integer.valueOf(this.a), this.b));
                        CoinWebViewFragment.this.Z = false;
                        CoinWebViewFragment.this.X = 0;
                        CoinWebViewFragment.this.Y = false;
                        CoinWebViewFragment.this.P = true;
                        boolean z = !CoinWebViewFragment.this.i0;
                        if (this.c.isTouchByUser()) {
                            com.iBookStar.utils.p.a("CoinWebViewFragment", String.format("ttttttttttttttt--3, loc=%d, url=%s", Integer.valueOf(this.a), this.b));
                            if (!CoinWebViewFragment.this.i0) {
                                com.iBookStar.utils.p.a("CoinWebViewFragment", String.format("ttttttttttttttt--4, loc=%d, url=%s", Integer.valueOf(this.a), this.b));
                                CoinWebViewFragment.this.m0.clear();
                                CoinWebViewFragment.this.m0.add(c2);
                                CoinWebViewFragment.this.z = 0.0f;
                                CoinWebViewFragment.this.B = 0;
                                CoinWebViewFragment.this.i0 = true;
                                if (!"buy".equalsIgnoreCase(CoinWebViewFragment.this.J) || !CoinWebViewFragment.this.d0) {
                                    com.iBookStar.utils.p.a("CoinWebViewFragment", String.format("ttttttttttttttt--5, loc=%d, url=%s", Integer.valueOf(this.a), this.b));
                                    CoinWebViewFragment.this.a((CoinWebViewFragment) false, true, (boolean) null, (String) null, (String) 0, 0L);
                                }
                            } else {
                                if (!CoinWebViewFragment.this.j0) {
                                    com.iBookStar.utils.p.a("CoinWebViewFragment", String.format("ttttttttttttttt--6, loc=%d, url=%s", Integer.valueOf(this.a), this.b));
                                    if (!"buy".equalsIgnoreCase(CoinWebViewFragment.this.J)) {
                                        CoinWebViewFragment.this.m0.add(c2);
                                        if (CoinWebViewFragment.this.m0.size() > 1) {
                                            CoinWebViewFragment.this.j0 = true;
                                        }
                                    } else {
                                        for (String str : CoinWebViewFragment.this.L) {
                                            if (this.b.contains(str)) {
                                                CoinWebViewFragment.this.j0 = true;
                                                CoinWebViewFragment.this.m0.add(this.b);
                                                com.iBookStar.a.d.a().c(CoinWebViewFragment.this.I);
                                            }
                                        }
                                    }
                                } else if (CoinWebViewFragment.this.m0.size() < 2) {
                                    if (!"buy".equalsIgnoreCase(CoinWebViewFragment.this.J)) {
                                        CoinWebViewFragment.this.m0.add(c2);
                                    } else {
                                        for (String str2 : CoinWebViewFragment.this.L) {
                                            if (this.b.contains(str2)) {
                                                CoinWebViewFragment.this.m0.add(this.b);
                                            }
                                        }
                                    }
                                }
                                com.iBookStar.a.d.a().c(CoinWebViewFragment.this.I);
                            }
                        }
                        CoinWebViewFragment.this.d((CoinWebViewFragment) false);
                        CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                        y yVar = coinWebViewFragment.k;
                        if (yVar != null) {
                            if (z) {
                                yVar.a(1, coinWebViewFragment.I != null ? CoinWebViewFragment.this.I.o() : 0);
                            }
                            CoinWebViewFragment coinWebViewFragment2 = CoinWebViewFragment.this;
                            y yVar2 = coinWebViewFragment2.k;
                            if (coinWebViewFragment2.T < 2) {
                                i = 0;
                            }
                            yVar2.a(i);
                            CoinWebViewFragment.this.k.c(this.c.getTitle());
                        }
                    }
                }
                this.c.resetTouchState();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class g implements Runnable {
        g() {
        }

        public void run() {
            CoinWebViewFragment.this.c0 = false;
            if (CoinWebViewFragment.this.P && !CoinWebViewFragment.this.a.isFinishing() && CoinWebViewFragment.this.i0 && !CoinWebViewFragment.this.j0) {
                CoinWebViewFragment.this.j0 = true;
                CoinWebViewFragment.this.m0.add(CoinWebViewFragment.this.c.getUrl());
                CoinWebViewFragment.this.d((CoinWebViewFragment) true);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class h implements Runnable {

        class a implements Runnable {
            a() {
            }

            public void run() {
                if (CoinWebViewFragment.this.P && !CoinWebViewFragment.this.a.isFinishing()) {
                    CoinWebViewFragment.this.a((CoinWebViewFragment) true, false, (boolean) "圆圈进度条走满完成任务", (String) null, (String) 0, 0L);
                }
            }
        }

        h() {
        }

        public void run() {
            boolean z = CoinWebViewFragment.this.V;
            CoinWebViewFragment.this.V = false;
            if (CoinWebViewFragment.this.P && !CoinWebViewFragment.this.a.isFinishing() && !CoinWebViewFragment.this.A && z) {
                CoinWebViewFragment.this.l0 = true;
                CoinWebViewFragment.this.e.tryProgressBarExpand(false, 0);
                CoinWebViewFragment.this.b.postDelayed(new a(), 300);
                CoinWebViewFragment.this.c((CoinWebViewFragment) true);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class i implements Runnable {
        final /* synthetic */ boolean a;
        final /* synthetic */ String b;

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

        public void run() {
            if (CoinWebViewFragment.this.P) {
                CoinWebViewFragment.this.a((CoinWebViewFragment) true, false, (boolean) "圆圈进度条走满完成任务", this.a ? null : this.b, (String) 0, 0L);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class j implements Runnable {
        j() {
        }

        public void run() {
            CoinWebViewFragment.this.e.setExpandDescAnim();
        }
    }

    /* access modifiers changed from: package-private */
    public class k implements Runnable {
        k() {
        }

        public void run() {
            CoinWebViewFragment.this.F = false;
            CoinWebViewFragment.this.e.hide();
        }
    }

    /* access modifiers changed from: package-private */
    public class l implements Runnable {
        l() {
        }

        public void run() {
            CoinWebViewFragment.this.e.setExpandDescAnim();
        }
    }

    /* access modifiers changed from: package-private */
    public class m implements Runnable {
        m() {
        }

        public void run() {
            CoinWebViewFragment.this.e.setExpandDescAnim();
        }
    }

    /* access modifiers changed from: package-private */
    public class n implements Runnable {

        class a implements Runnable {

            /* renamed from: com.iBookStar.activityComm.CoinWebViewFragment$n$a$a  reason: collision with other inner class name */
            class RunnableC0059a implements Runnable {
                RunnableC0059a() {
                }

                public void run() {
                    CoinWebViewFragment.this.O = false;
                    CoinWebViewFragment.this.x();
                }
            }

            a() {
            }

            public void run() {
                CoinWebViewFragment.this.r();
                CoinWebViewFragment.this.b.postDelayed(new RunnableC0059a(), 300);
            }
        }

        n() {
        }

        public void run() {
            CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
            coinWebViewFragment.e.setExpandTips(null, coinWebViewFragment.N, 0);
            CoinWebViewFragment.this.e.show();
            CoinWebViewFragment.this.e.setCoinMode(1);
            CoinWebViewFragment.this.e.setProgressBarBackground(1);
            CoinWebViewFragment.this.e.setCoinText("");
            CoinWebViewFragment.this.e.tryProgressBarExpand(true, 0);
            CoinWebViewFragment.this.b.postDelayed(new a(), 3000);
            try {
                CoinWebViewFragment.this.c.loadUrl("javascript:if(window.reportQuitPrompt) {window.reportQuitPrompt()}");
            } catch (Throwable unused) {
            }
        }
    }

    class o implements Runnable {
        final /* synthetic */ Intent a;

        o(Intent intent) {
            this.a = intent;
        }

        public void run() {
            CoinWebViewFragment.this.F = false;
            if (!this.a.getBooleanExtra(PointCategory.REPORT, false)) {
                boolean booleanExtra = this.a.getBooleanExtra("click", false);
                CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                coinWebViewFragment.a((CoinWebViewFragment) coinWebViewFragment.t, (com.iBookStar.a.g) (booleanExtra ? 1 : 2));
                CoinWebViewFragment.this.G = true;
                return;
            }
            CoinWebViewFragment.this.t();
            CoinWebViewFragment.this.h();
            CoinWebViewFragment.this.q();
        }
    }

    /* access modifiers changed from: package-private */
    public class p implements l.m {
        p() {
        }

        @Override // com.iBookStar.utils.l.m
        public boolean a(int i, int i2, Object obj, Object... objArr) {
            if (i2 == 0) {
                CoinWebViewFragment.this.h = String.format("%s%s", com.iBookStar.c.b.a("reward_unit", "金币"), String.valueOf(obj));
                CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                if (coinWebViewFragment.k != null && !coinWebViewFragment.P) {
                    CoinWebViewFragment coinWebViewFragment2 = CoinWebViewFragment.this;
                    coinWebViewFragment2.k.b(coinWebViewFragment2.h);
                }
            }
            return true;
        }
    }

    /* access modifiers changed from: package-private */
    public class q implements l.m {
        final /* synthetic */ com.iBookStar.a.g a;

        q(com.iBookStar.a.g gVar) {
            this.a = gVar;
        }

        @Override // com.iBookStar.utils.l.m
        public boolean a(int i, int i2, Object obj, Object... objArr) {
            try {
                CoinWebViewFragment.this.G = false;
                if (i2 == 0) {
                    com.iBookStar.a.g gVar = this.a;
                    gVar.f(gVar.k() - 1);
                    if (this.a.k() <= 0) {
                        this.a.d(1);
                    }
                    com.iBookStar.c.b.a(com.iBookStar.c.c.b("ad_task_fail"));
                } else {
                    com.iBookStar.c.b.b(com.iBookStar.c.c.b("ad_task_fail"), System.currentTimeMillis());
                }
                String str = (String) obj;
                if (CoinWebViewFragment.this.k != null) {
                    CoinWebViewFragment.this.k.d(str);
                }
                if (objArr != null && objArr.length > 0) {
                    this.a.f((String) objArr[0]);
                    CoinWebViewFragment.this.t();
                }
                CoinWebViewFragment.this.h();
                CoinWebViewFragment.this.q();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        }
    }

    /* access modifiers changed from: package-private */
    public class r implements Runnable {

        class a implements Runnable {
            a() {
            }

            public void run() {
                CoinWebViewFragment.this.e.setExpandDescAnim();
            }
        }

        r() {
        }

        public void run() {
            String str;
            CoinWebViewFragment.this.F = false;
            com.iBookStar.a.g a2 = com.iBookStar.c.b.a(0);
            if (a2 != null) {
                str = a2.m() + "用户通过下一关";
            } else {
                str = "80%用户通过下一关";
            }
            CoinWebViewFragment.this.a(true, str, "【继续下一关】", 0, 0);
            CoinWebViewFragment.this.b.postDelayed(new a(), 300);
        }
    }

    /* access modifiers changed from: package-private */
    public class s implements Runnable {

        class a implements Runnable {
            a() {
            }

            public void run() {
                CoinWebViewFragment.this.e.setExpandDescAnim();
            }
        }

        s() {
        }

        public void run() {
            CoinWebViewFragment.this.F = false;
            CoinWebViewFragment.this.a(true, "恭喜完成今日通关任务", "【领取通关奖励】", 0, 0);
            CoinWebViewFragment.this.b.postDelayed(new a(), 300);
        }
    }

    /* access modifiers changed from: package-private */
    public class t implements Runnable {

        class a implements Runnable {
            a() {
            }

            public void run() {
                CoinWebViewFragment.this.e.setExpandDescAnim();
            }
        }

        t() {
        }

        public void run() {
            CoinWebViewFragment.this.F = false;
            CoinWebViewFragment.this.a(true, "恭喜完成7天连续通关任务", "【领取现金红包】", 0, 0);
            CoinWebViewFragment.this.b.postDelayed(new a(), 300);
        }
    }

    /* access modifiers changed from: package-private */
    public class u implements Runnable {
        u() {
        }

        public void run() {
            CoinWebViewFragment.this.F = false;
            if (!CoinWebViewFragment.this.S) {
                com.iBookStar.utils.v.a(CoinWebViewFragment.this.R);
            } else {
                CoinWebViewFragment.this.q.putExtra("opennext", true);
            }
            CoinWebViewFragment.this.a(true, false);
        }
    }

    class v implements Runnable {
        final /* synthetic */ com.iBookStar.utils.j a;

        v(com.iBookStar.utils.j jVar) {
            this.a = jVar;
        }

        public void run() {
            CoinWebViewFragment.this.a((CoinWebViewFragment) this.a.a());
        }
    }

    /* access modifiers changed from: package-private */
    public class w implements SdkAdMonitorView.e {
        w() {
        }

        @Override // com.iBookStar.views.SdkAdMonitorView.e
        public void a() {
            CoinWebViewFragment.this.Y = true;
            if (!CoinWebViewFragment.this.H) {
                CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                coinWebViewFragment.a((CoinWebViewFragment) coinWebViewFragment.t, (com.iBookStar.a.g) 1);
                CoinWebViewFragment.this.G = true;
                CoinWebViewFragment.this.n();
                CoinWebViewFragment.this.Y = false;
                CoinWebViewFragment.this.X = 0;
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class x extends Thread {

        class a implements Runnable {

            /* renamed from: com.iBookStar.activityComm.CoinWebViewFragment$x$a$a  reason: collision with other inner class name */
            class RunnableC0060a implements Runnable {
                RunnableC0060a() {
                }

                public void run() {
                    CoinWebViewFragment.this.F = false;
                    CoinWebViewFragment.this.G = true;
                    CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                    coinWebViewFragment.a((CoinWebViewFragment) coinWebViewFragment.t, (com.iBookStar.a.g) 1);
                }
            }

            a() {
            }

            public void run() {
                if (!CoinWebViewFragment.this.e.isShow()) {
                    return;
                }
                if (CoinWebViewFragment.this.z >= 360.0f) {
                    CoinWebViewFragment.this.F = true;
                    CoinWebViewFragment.this.l0 = true;
                    CoinWebViewFragment.this.r();
                    CoinWebViewFragment.this.b.postDelayed(new RunnableC0060a(), 300);
                    return;
                }
                CoinWebViewFragment.this.y();
                CoinWebViewFragment.this.z();
            }
        }

        x() {
        }

        public void run() {
            do {
                if (!CoinWebViewFragment.this.H) {
                    CoinWebViewFragment.g(CoinWebViewFragment.this);
                    if (CoinWebViewFragment.this.z >= ((float) CoinWebViewFragment.this.B)) {
                        CoinWebViewFragment.this.A = false;
                        CoinWebViewFragment coinWebViewFragment = CoinWebViewFragment.this;
                        coinWebViewFragment.z = (float) coinWebViewFragment.B;
                        Activity activity = CoinWebViewFragment.this.a;
                        if (activity != null && !activity.isFinishing()) {
                            CoinWebViewFragment.this.a.runOnUiThread(new a());
                        }
                    }
                    CoinWebViewFragment coinWebViewFragment2 = CoinWebViewFragment.this;
                    coinWebViewFragment2.e.setProgress(coinWebViewFragment2.z);
                }
                try {
                    Thread.sleep((long) CoinWebViewFragment.this.w);
                } catch (Exception unused) {
                }
            } while (CoinWebViewFragment.this.A);
        }
    }

    public interface y {
        void a(int i);

        void a(int i, int i2);

        void a(String str);

        void b(String str);

        void c(String str);

        void d(String str);
    }

    private PopupWebView a(String str) {
        if (this.a.isFinishing() || com.iBookStar.utils.s.a(str)) {
            return null;
        }
        return this.W.get(str);
    }

    private String a(int i2) {
        if (i2 == 1) {
            if ("theme".equalsIgnoreCase(this.J)) {
                return com.iBookStar.c.c.a("thd_1", "参与互动游戏领取福利");
            }
            if ("buy".equalsIgnoreCase(this.J)) {
                return (!this.d0 || !com.iBookStar.utils.s.c(this.e0)) ? com.iBookStar.c.c.a("tyhq_1", "挑选宝贝后进入详情页领取优惠券") : this.e0;
            }
            int i3 = this.f102K;
            return i3 == 1 ? com.iBookStar.c.c.a("tjs_1", "选择广告点击进入后查看") : i3 == 2 ? com.iBookStar.c.c.a("tapi_1", "选择广告点击进入后查看") : "选择广告点击进入后查看";
        } else if ("theme".equalsIgnoreCase(this.J)) {
            return com.iBookStar.c.c.a("thd_2", "领取成功/请尽快使用您的福利");
        } else {
            if ("buy".equalsIgnoreCase(this.J)) {
                return (!this.d0 || !com.iBookStar.utils.s.c(this.f0)) ? com.iBookStar.c.c.a("tyhq_2", "领券成功/下单购买立省50%") : this.f0;
            }
            int i4 = this.f102K;
            return i4 == 1 ? com.iBookStar.c.c.a("tjs_2", "继续参与广告进度条走满可得奖励") : i4 == 2 ? com.iBookStar.c.c.a("tapi_2", "继续参与广告进度条走满可得奖励") : "继续参与广告进度条走满可得奖励";
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(Activity activity) {
        if (!activity.isFinishing()) {
            String className = activity.getComponentName().getClassName();
            if (className.startsWith("com.baidu.mobads") || className.startsWith("com.sogou.feedads") || className.startsWith("com.qq.e") || className.startsWith(BuildConfig.LIBRARY_PACKAGE_NAME)) {
                ((SdkAdMonitorView) LayoutInflater.from(activity).inflate(com.iBookStar.utils.k.a(R.layout.ym_sdkad_tip, "ym_sdkad_tip", TtmlNode.TAG_LAYOUT), (ViewGroup) null)).show(activity, true, this.y, this.x, new w());
                this.Z = false;
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(com.iBookStar.a.g gVar, int i2) {
        try {
            com.iBookStar.utils.l.a(new q(gVar), gVar.l(), i2);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(CommonWebView commonWebView, String str, int i2) {
        this.b.postDelayed(new f(i2, str, commonWebView), 1000);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(boolean z2, String str, String str2, long j2, long j3) {
        a(z2, true, str, str2, j2, j3);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(boolean z2, boolean z3, String str, String str2, long j2, long j3) {
        w();
        if (z3) {
            this.e.setProgress(0.0f);
        }
        if (z2) {
            this.e.setExpandTips(str, str2, j3);
            this.e.show();
            this.e.tryProgressBarExpand(true, j2);
            return;
        }
        this.e.show();
        this.e.tryProgressBarExpand(false, 0);
    }

    private void b(int i2) {
        if (this.E == 0 && this.v == 0 && !this.i0 && !this.j0) {
            this.i0 = true;
            this.j0 = true;
            this.k0 = true;
            this.l0 = true;
            int i3 = this.x / 60;
            if (i3 < 1) {
                i3 = 1;
            }
            a(true, true, "圆圈进度条走满完成任务", this.t.g().replace("${time}", String.valueOf(i3)), 0L, 2000L);
            if (Math.abs(((float) i2) - ((float) (this.c.getHeight() + this.c.getScrollY()))) < 201.0f || this.x <= 5) {
                c(true);
            } else {
                c(false);
            }
        }
    }

    private boolean b(boolean z2) {
        if (!z2 || this.S || !this.M || this.O) {
            return false;
        }
        this.O = true;
        r();
        this.b.postDelayed(new n(), 300);
        return true;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void c(boolean z2) {
        if (this.z < 360.0f) {
            if (z2) {
                this.B = BitmapUtils.ROTATE360;
            } else {
                int i2 = this.B;
                if (i2 < 360) {
                    this.B = i2 + 120;
                }
            }
            v();
            if (!this.A) {
                this.A = true;
                new x().start();
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void d(boolean z2) {
        if (this.e.isShow() && this.E == 0) {
            int i2 = 2;
            if (!this.j0 || this.m0.size() <= 1) {
                if (this.i0 && this.m0.size() > 0 && !this.k0) {
                    this.k0 = true;
                    int i3 = this.v;
                    if (i3 > 1) {
                        a(true, "圆圈进度条走满完成任务", a(1), 0, 2000);
                    } else if (i3 > 0) {
                        this.j0 = true;
                        if (!"buy".equalsIgnoreCase(this.J) && !"theme".equalsIgnoreCase(this.J)) {
                            this.l0 = true;
                        }
                        if (!this.l0) {
                            i2 = 1;
                        }
                        a(true, "圆圈进度条走满完成任务", a(i2), 0, 2000);
                    }
                } else {
                    return;
                }
            } else if (!this.l0) {
                this.l0 = true;
                String a2 = a(2);
                this.e.tryProgressBarExpand(false, 0);
                this.b.postDelayed(new i(z2, a2), 300);
                if (z2) {
                    c(true);
                    return;
                }
            } else {
                return;
            }
            c(false);
        }
    }

    static /* synthetic */ float g(CoinWebViewFragment coinWebViewFragment) {
        float f2 = coinWebViewFragment.z;
        coinWebViewFragment.z = 1.0f + f2;
        return f2;
    }

    private boolean i() {
        if (this.a0 || this.E <= 0 || !this.P || !l() || !com.iBookStar.utils.s.c(this.U) || this.j0) {
            return false;
        }
        this.J = "";
        this.A = false;
        this.z = 0.0f;
        this.B = 0;
        this.i0 = false;
        this.j0 = false;
        this.k0 = false;
        this.l0 = false;
        this.V = false;
        this.c0 = false;
        this.m0.clear();
        this.c.setTouchByUser();
        NativeAdUtil.getInstance().click(this.c, this.U, 0, 0, 0, 0, false, true);
        this.q.putExtra("iBackAdId", this.U);
        this.U = null;
        this.a0 = true;
        return true;
    }

    private boolean j() {
        if (this.a0 || this.E <= 0 || !this.P || !l() || !k()) {
            return false;
        }
        this.J = "";
        this.A = false;
        this.z = 0.0f;
        this.B = 0;
        this.i0 = false;
        this.j0 = false;
        this.k0 = false;
        this.l0 = false;
        this.V = false;
        this.c0 = false;
        this.m0.clear();
        this.c.setTouchByUser();
        this.c.loadUrl(String.format("javascript:location.replace('%s')", com.iBookStar.c.b.a("promotion_page_url", "")));
        this.a0 = true;
        return true;
    }

    private boolean k() {
        return false;
    }

    private boolean l() {
        try {
            if (this.S && !this.c.canGoBack()) {
                return true;
            }
            CommonWebView.c2 copyBackForwardList = this.c.copyBackForwardList();
            if (copyBackForwardList.a() == 0) {
                return true;
            }
            String c2 = com.iBookStar.utils.k.c(copyBackForwardList.a(copyBackForwardList.a() - 1).b());
            return com.iBookStar.utils.s.c(c2) && c2.equalsIgnoreCase(this.s);
        } catch (Throwable th) {
            th.printStackTrace();
            return false;
        }
    }

    private void m() {
        try {
            JSONObject jSONObject = new JSONObject(getArguments().getString("taskParams"));
            this.E = jSONObject.optInt("iCurrentTaskState", 0);
            this.s = jSONObject.optString("iDefaultHost", null);
            this.J = jSONObject.optString("iTaskType", PointCategory.SHOW);
            this.f102K = jSONObject.optInt("iIsJs", 0);
            this.x = jSONObject.optInt("iDuration", 15);
            this.w = jSONObject.optInt("iSpeed", 30);
            JSONArray optJSONArray = jSONObject.optJSONArray("iTaskBuyParams");
            if (optJSONArray != null && optJSONArray.length() > 0) {
                for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
                    this.L.add(optJSONArray.getString(i2));
                }
            }
            this.U = jSONObject.optString("iBackAdId", null);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void n() {
        if (!this.a.isFinishing() && this.I != null && !o() && !this.c.reloadFloatNativeAd(this.I)) {
            this.c.reloadNativeAd(this.I);
        }
    }

    private boolean o() {
        if (this.I == null) {
            return false;
        }
        for (PopupWebView popupWebView : this.W.values()) {
            if (this.I.equals(popupWebView.getAdItem())) {
                popupWebView.reloadAd();
                return true;
            }
        }
        return false;
    }

    private void p() {
        y yVar;
        if (this.T >= 2 && this.P && (yVar = this.k) != null) {
            yVar.a(2);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void q() {
        Runnable runnable;
        RelativeLayout relativeLayout;
        int i2 = this.E;
        if (i2 == 0) {
            this.E = 1;
            int[] g2 = com.iBookStar.c.b.g();
            if (g2 != null && g2[0] > 0) {
                this.F = true;
                r();
                relativeLayout = this.b;
                runnable = new r();
            } else if (this.u != null) {
                this.E = 2;
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("task_state_for_reward_open"), 2);
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("task_complete_notify"), System.currentTimeMillis());
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("task_complete_time"), System.currentTimeMillis());
                com.iBookStar.utils.v.l();
                this.F = true;
                r();
                relativeLayout = this.b;
                runnable = new s();
            } else {
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("task_state_for_reward_open"), 2);
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("task_complete_notify"), System.currentTimeMillis());
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("task_complete_time"), System.currentTimeMillis());
                com.iBookStar.utils.v.l();
                this.F = true;
                r();
                relativeLayout = this.b;
                runnable = new t();
            }
            relativeLayout.postDelayed(runnable, 300);
        } else if (i2 == 2) {
            this.F = true;
            this.b.postDelayed(new u(), 1000);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void r() {
        if (!this.e.isShow() || !this.e.isProgressBarExpand()) {
            this.e.hide();
            return;
        }
        this.F = true;
        this.e.tryProgressBarExpand(false, 0);
        this.b.postDelayed(new k(), 300);
    }

    private void s() {
        if (this.E == 0 && this.v > 0) {
            if (this.i0 && this.z < 360.0f) {
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("ad_task_fail"), System.currentTimeMillis());
                u();
            }
            if (this.e.isShow()) {
                r();
            }
        }
        this.J = "";
        this.L.clear();
        this.A = false;
        this.z = 0.0f;
        this.B = 0;
        this.d0 = false;
        this.T = 0;
        this.i0 = false;
        this.j0 = false;
        this.k0 = false;
        this.l0 = false;
        this.m0.clear();
        this.X = 0;
        this.Z = false;
        this.a0 = false;
        this.I = null;
        this.V = false;
        this.c0 = false;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void t() {
        if (!this.P && com.iBookStar.utils.s.c(this.t.i())) {
            try {
                CommonWebView commonWebView = this.c;
                commonWebView.loadUrl("javascript:if(window.onReportEndSuccess){window.onReportEndSuccess(" + this.t.i() + ")}");
            } catch (Exception e2) {
                e2.printStackTrace();
            } catch (Throwable th) {
                this.t.f((String) null);
                throw th;
            }
            this.t.f((String) null);
        }
    }

    private void u() {
        try {
            this.c.loadUrl("javascript:if(window.onTaskDetectFail) {window.onTaskDetectFail()}");
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    private void v() {
        String str;
        if (this.V) {
            if (!this.d0 || !com.iBookStar.utils.s.c(this.h0)) {
                int i2 = 1;
                if (this.v == 0) {
                    int i3 = this.x / 60;
                    if (i3 >= 1) {
                        i2 = i3;
                    }
                    str = this.t.g().replace("${time}", String.valueOf(i2));
                } else {
                    if (this.l0) {
                        i2 = 2;
                    }
                    str = a(i2);
                }
                this.e.setExpandDesc(str);
            } else {
                this.e.setExpandDesc(this.h0);
            }
            this.V = false;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0080, code lost:
        if (r0.length() >= 5) goto L_0x0082;
     */
    private void w() {
        TaskProgressBar taskProgressBar;
        String str;
        int i2 = this.E;
        int i3 = 5;
        if (i2 == 0) {
            this.e.setCoinMode(2);
            this.e.setProgressBarBackground(1);
            float f2 = 1.6f;
            if ("0".equalsIgnoreCase(this.t.d())) {
                str = "?";
            } else {
                if (this.t.d().indexOf(46) == -1) {
                    int parseInt = Integer.parseInt(this.t.d());
                    if (parseInt < 10000) {
                        str = String.valueOf(parseInt);
                    } else if (parseInt % 10000 == 0 || parseInt >= 1000000) {
                        str = String.format("%d万", Integer.valueOf(parseInt / 10000));
                    } else {
                        str = String.format("%.1f万", Float.valueOf(((float) parseInt) / 10000.0f));
                    }
                } else {
                    str = this.t.d();
                }
                f2 = 1.3f;
            }
            String str2 = com.iBookStar.c.b.a("reward_unit", "金币") + "\n" + str;
            int indexOf = str2.indexOf(10);
            SpannableString spannableString = new SpannableString(str2);
            spannableString.setSpan(new RelativeSizeSpan(f2), indexOf, str2.length(), 33);
            this.e.setCoinSpannedText(spannableString);
            return;
        }
        if (i2 == 1) {
            taskProgressBar = this.e;
        } else if (i2 == 2) {
            taskProgressBar = this.e;
            i3 = 7;
        } else {
            return;
        }
        taskProgressBar.setCoinMode(i3);
        this.e.setProgressBarBackground(1);
        this.e.setCoinText("");
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void x() {
        Runnable runnable;
        RelativeLayout relativeLayout;
        String str;
        int i2 = this.E;
        int i3 = 1;
        if (i2 != 0) {
            if (i2 == 1) {
                int[] g2 = com.iBookStar.c.b.g();
                if (g2 == null || g2[0] <= 0) {
                    a(true, "连续通关7天领现金红包", "【恭喜通关】", 0, 0);
                    relativeLayout = this.b;
                    runnable = new l();
                } else {
                    com.iBookStar.a.g a2 = com.iBookStar.c.b.a(0);
                    if (a2 != null) {
                        str = a2.m() + "用户通过下一关";
                    } else {
                        str = "80%用户通过下一关";
                    }
                    a(true, str, "【继续下一关】", 0, 0);
                    relativeLayout = this.b;
                    runnable = new j();
                }
            } else if (i2 == 2) {
                a(true, "点击领取通关奖励和红包", "【恭喜通关】", 0, 0);
                relativeLayout = this.b;
                runnable = new m();
            } else {
                return;
            }
            relativeLayout.postDelayed(runnable, 300);
        } else if (this.v == 0) {
            int b2 = this.t.b() / 60;
            if (b2 >= 1) {
                i3 = b2;
            }
            a(true, false, "圆圈进度条走满完成任务", this.t.g().replace("${time}", String.valueOf(i3)), 0L, 2000L);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void y() {
        if (!this.j0 && !this.c0) {
            this.c0 = true;
            this.e.setExpandDescAnim();
            this.b.postDelayed(new g(), (long) (this.y * 1000));
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void z() {
        String str;
        TaskProgressBar taskProgressBar;
        if (this.j0 && !this.A && !this.V) {
            this.V = true;
            if (!this.d0 || !com.iBookStar.utils.s.c(this.g0)) {
                taskProgressBar = this.e;
                str = "滑动页面正常浏览进度才会走";
            } else {
                taskProgressBar = this.e;
                str = this.g0;
            }
            taskProgressBar.setExpandDesc(str);
            this.e.setExpandDescAnim();
            this.b.postDelayed(new h(), (long) (this.y * 1000));
        }
    }

    public void a() {
        int color = getResources().getColor(com.iBookStar.utils.k.a(R.color.ym_client_bg, "ym_client_bg", "color"));
        this.b.setBackgroundColor(color);
        this.d.setProgressDrawableEx(getResources().getDrawable(com.iBookStar.utils.k.a(R.drawable.ym_progress_bar_states, "ym_progress_bar_states", "drawable")), YmConfig.getWebViewProgressColor(), new ColorDrawable(color));
    }

    public void a(y yVar) {
        this.k = yVar;
    }

    public void a(CoinWebViewFragment coinWebViewFragment) {
        if (coinWebViewFragment != null) {
            n0.remove(coinWebViewFragment);
            coinWebViewFragment.a.finish();
        }
    }

    public void a(TaskProgressBar taskProgressBar) {
        this.e = taskProgressBar;
    }

    /* access modifiers changed from: protected */
    public void a(boolean z2) {
        this.e.setListener(new b());
        SkinProgressBar skinProgressBar = (SkinProgressBar) this.b.findViewById(com.iBookStar.utils.k.a(R.id.ym_webview_progress, "ym_webview_progress", "id"));
        this.d = skinProgressBar;
        skinProgressBar.setMax(this.f);
        CommonWebView commonWebView = (CommonWebView) this.b.findViewById(com.iBookStar.utils.k.a(R.id.ym_content_wv, "ym_content_wv", "id"));
        this.c = commonWebView;
        commonWebView.initWebView(z2);
        this.c.setPromptDownload(false);
        this.c.setCommonWebViewClient(new c());
        this.c.setCommonWebChromeClient(new d());
        this.c.setCommonWebViewListener(this);
        this.c.setOnTouchListener(new e());
    }

    public void a(boolean z2, boolean z3) {
        if (!this.F && !this.G && !this.o) {
            if (!z2 && (j() || i())) {
                this.T++;
                p();
            } else if (!z2 && b()) {
                this.c.setTouchByUser();
                this.c.goBack();
                if (this.P) {
                    this.T++;
                    p();
                }
            } else if (!b(z3)) {
                int i2 = -1;
                if (this.m) {
                    i2 = 101;
                } else if (this.n) {
                    i2 = 102;
                }
                this.q.putExtra("iCurrentTaskState", this.E);
                this.a.setResult(i2, this.q);
                a(this);
            }
        }
    }

    public boolean a(int i2, KeyEvent keyEvent) {
        if (i2 != 4) {
            return false;
        }
        a(false, true);
        return true;
    }

    public boolean a(CommonWebView commonWebView, String str) {
        if (com.iBookStar.utils.s.a(str) || (!str.startsWith("http://") && !str.startsWith("https://"))) {
            return false;
        }
        if (str.contains("dbnewopen") || str.contains("dbnewopenbackrefresh")) {
            Intent intent = new Intent();
            intent.setClass(this.a, SurveyWebView.class);
            intent.putExtra("url", str);
            startActivityForResult(intent, 101);
            return true;
        } else if (str.contains("dbbackrefresh")) {
            Intent intent2 = new Intent();
            if (str.contains("dbbackrefreshex")) {
                intent2.putExtra("url", str.replace("dbbackrefreshex", "none"));
            }
            this.a.setResult(100, intent2);
            a(this);
            return true;
        } else if (str.contains("dbbackrootrefresh")) {
            if (n0.size() < 2) {
                a(this);
            } else {
                n0.get(1).a.setResult(100);
                c();
            }
            return true;
        } else if (str.contains("dbbackroot")) {
            if (n0.size() == 1) {
                a(this);
            } else {
                c();
            }
            return true;
        } else if (str.contains("dbback")) {
            a(this);
            return true;
        } else if (!this.j || str.equalsIgnoreCase(this.i)) {
            return false;
        } else {
            Bundle bundle = new Bundle();
            bundle.putString(CampaignEx.JSON_KEY_TITLE, com.iBookStar.utils.s.c(this.g) ? this.g : "");
            bundle.putString("url", str);
            Intent intent3 = new Intent(this.a, SurveyWebView.class);
            intent3.putExtras(bundle);
            startActivityForResult(intent3, 100);
            return true;
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void aSetUserBindRelation(String str) {
    }

    public boolean b() {
        return !this.l && this.c.canGoBack();
    }

    public void c() {
        int size = n0.size();
        for (int i2 = 0; i2 < size - 1; i2++) {
            n0.pop().a.finish();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void clickToPushSetting() {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void createPopupWindow(String str, String str2) {
        PopupWebView a2 = a(str);
        if (a2 == null) {
            a2 = new PopupWebView(this.a);
            this.W.put(str, a2);
        }
        a2.preparePopupWindow(this.c);
        a2.createPopupWindow(str, str2);
    }

    public void d() {
        if (!this.F && !this.G) {
            int i2 = 0;
            if (this.S) {
                a(true, false);
                return;
            }
            try {
                CommonWebView.c2 copyBackForwardList = this.c.copyBackForwardList();
                if (copyBackForwardList != null) {
                    for (int a2 = copyBackForwardList.a(); a2 >= 0; a2--) {
                        String c2 = com.iBookStar.utils.k.c(copyBackForwardList.a(a2).b());
                        if (!com.iBookStar.utils.s.c(c2) || !c2.equalsIgnoreCase(this.s)) {
                            i2--;
                        } else if (i2 < 0) {
                            this.c.goBackOrForward(i2);
                            return;
                        } else {
                            return;
                        }
                    }
                }
                this.c.goBack();
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void dealPics(String str) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void destroyPopupWindow(String str) {
        PopupWebView a2 = a(str);
        if (a2 != null) {
            a2.destroyPopupWindow(str);
        }
    }

    public void e() {
        if (com.iBookStar.utils.s.a(this.c.getOriginalUrl())) {
            this.c.loadUrl(this.i);
        } else {
            this.c.reload();
        }
    }

    public void f() {
        this.c.refreshContent();
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void fetchAd(String str) {
    }

    public void g() {
        try {
            if (com.iBookStar.utils.s.c(this.b0)) {
                CommonWebView commonWebView = this.c;
                String str = this.b0;
                commonWebView.loadUrl(String.format("javascript:if(%s){%s()}", str, str));
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getCoinTaskProgress() {
        JSONObject jSONObject = new JSONObject();
        try {
            int[] g2 = com.iBookStar.c.b.g();
            if (g2 != null) {
                jSONObject.put("curPos", g2[1] - g2[0]);
                jSONObject.put("totalCount", g2[1]);
            }
            com.iBookStar.a.g h2 = com.iBookStar.c.b.h();
            if (h2 != null) {
                jSONObject.put("big_gift_pack", h2.f());
            }
            return jSONObject.toString();
        } catch (Throwable th) {
            th.printStackTrace();
            return null;
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getCurrentCoinTask() {
        try {
            return this.t.f().toString();
        } catch (Throwable th) {
            th.printStackTrace();
            return null;
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public long getCurrentTaskId() {
        return this.t.l();
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void getMonitorTime(String str) {
        try {
            CommonWebView commonWebView = this.c;
            commonWebView.loadUrl(String.format("javascript:if(%s){%s(%d)}", str, str, Integer.valueOf(this.x)));
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getTaskParams() {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("iCurrentTaskState", this.E);
            jSONObject.put("iDefaultHost", this.s);
            jSONObject.put("iTaskType", this.J);
            jSONObject.put("iIsJs", this.f102K);
            jSONObject.put("iDuration", this.x);
            jSONObject.put("iSpeed", this.w);
            jSONObject.put("iTaskBuyParams", this.L);
            jSONObject.put("iBackAdId", this.U);
            return jSONObject.toString();
        } catch (Throwable th) {
            th.printStackTrace();
            return null;
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public float getTopSafeAreaInset() {
        return 0.0f;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getUserBindRelation() {
        return null;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getUserSpecialId() {
        return null;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getUtdid() {
        return null;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public int getWebViewEnvironment() {
        return 4;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String getYPProductData() {
        return null;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void gotoTab(String str) {
    }

    public void h() {
        if (com.iBookStar.c.b.a(com.iBookStar.c.c.a("project_valid"), true)) {
            com.iBookStar.utils.l.e(new p());
        }
        WebViewFragment.B0 = true;
        o0 = false;
    }

    @com.iBookStar.utils.t
    public void handleAdClick(com.iBookStar.utils.e eVar) {
        com.iBookStar.a.f fVar;
        if (this.E == 0) {
            this.Z = true;
            this.X = System.currentTimeMillis();
            this.Y = false;
            if (eVar.a() && (fVar = this.I) != null) {
                this.c.loadUrl(String.format("javascript:if(window.onNativeAdClick){window.onNativeAdClick('%s')}", fVar.y()));
            }
        }
    }

    @com.iBookStar.utils.t
    public void handleSdkAdLpOpen(com.iBookStar.utils.j jVar) {
        com.iBookStar.a.f fVar;
        if (this.E == 0 && this.v > 0 && (fVar = this.I) != null && !"motivated".equalsIgnoreCase(fVar.h()) && System.currentTimeMillis() - this.X < 2000) {
            this.b.postDelayed(new v(jVar), 500);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void hidePopupWindow(String str) {
        PopupWebView a2 = a(str);
        if (a2 != null) {
            a2.hidePopupWindow(str);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void hrefNumOnPage(int i2) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String isEnterReaderFromTask() {
        return "0";
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public String isTaskFail() {
        try {
            return com.iBookStar.c.b.a("ad_task_fail_handle", 1) != 1 ? "0" : ((this.v <= 0 || !this.i0 || this.z >= 360.0f) && System.currentTimeMillis() - com.iBookStar.c.b.a(com.iBookStar.c.c.b("ad_task_fail"), 0) >= 300000) ? "0" : "1";
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void needPost() {
        if (!this.r) {
            String url = this.c.getUrl();
            if (com.iBookStar.utils.s.a(url)) {
                url = this.i;
            }
            this.s = com.iBookStar.utils.k.c(url);
            this.r = true;
        }
    }

    @Override // androidx.fragment.app.Fragment
    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        this.c.registerEventBus();
        com.iBookStar.utils.w.a().b(this);
    }

    @Override // androidx.fragment.app.Fragment
    public void onActivityResult(int i2, int i3, Intent intent) {
        super.onActivityResult(i2, i3, intent);
        this.c.onActivityResult(i2, i3, intent);
        if (i2 == 100) {
            if (i3 == -1) {
                e();
            }
        } else if (i2 == 101) {
            if (i3 == 100) {
                if (!(intent == null || intent.getStringExtra("url") == null)) {
                    String stringExtra = intent.getStringExtra("url");
                    this.i = stringExtra;
                    this.c.loadUrl(stringExtra);
                    return;
                }
            } else if (i3 != 101) {
                if (i3 == 102) {
                    f();
                    return;
                }
                return;
            }
            this.c.reload();
        } else {
            if (i2 == 20000) {
                this.Z = false;
                this.X = 0;
                this.Y = false;
                if (i3 != -1) {
                    return;
                }
                if (intent.getBooleanExtra("complete", false)) {
                    try {
                        if (intent.getBooleanExtra("taskMode", false)) {
                            this.F = true;
                            r();
                            this.b.postDelayed(new o(intent), 300);
                            return;
                        }
                        return;
                    } catch (Exception unused) {
                        return;
                    }
                } else {
                    String format = String.format("javascript:if(window.onRewardVideoFail){window.onRewardVideoFail('%s', [\"%s\"])}", intent.getStringExtra("adId"), intent.getStringExtra(com.sigmob.sdk.base.h.k));
                    System.out.println(format);
                    this.c.loadUrl(format);
                    if (!intent.getBooleanExtra("taskMode", false)) {
                        return;
                    }
                }
            } else if (i2 == 20001) {
                this.Z = false;
                this.X = 0;
                this.Y = false;
                n();
                if (intent != null) {
                    String stringExtra2 = intent.getStringExtra("iBackAdId");
                    if (com.iBookStar.utils.s.c(stringExtra2) && stringExtra2.equalsIgnoreCase(this.U)) {
                        this.U = null;
                    }
                    int intExtra = intent.getIntExtra("iCurrentTaskState", 0);
                    this.E = intExtra;
                    if (intExtra > 0) {
                        t();
                        if (intent.getBooleanExtra("opennext", false)) {
                            com.iBookStar.utils.v.a(this.R);
                            a(true, false);
                            return;
                        }
                        x();
                        return;
                    }
                }
                com.iBookStar.c.b.b(com.iBookStar.c.c.b("ad_task_fail"), System.currentTimeMillis());
            } else {
                return;
            }
            u();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onBackAdReceived(String str) {
        this.U = str;
        NativeAdUtil.getInstance().show(str);
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onClickTasksCenter() {
        com.iBookStar.c.b.a(com.iBookStar.c.c.b("task_state_for_reward_open"));
        Toast.makeText(this.a, "已经在进行任务连续闯关了", 0).show();
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onClose() {
        a(true, false);
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onContentLoaded(String str) {
        try {
            b(new JSONObject(str).optInt("scrollHeight"));
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onContinueAd() {
    }

    @Override // androidx.fragment.app.Fragment
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.a = getActivity();
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        n0.push(this);
        boolean z2 = getArguments().getBoolean("useX5", false);
        this.R = getArguments().getBoolean("back");
        this.S = getArguments().getBoolean("h5AdLandingPage", false);
        this.t = com.iBookStar.c.b.a(0);
        this.u = com.iBookStar.c.b.h();
        if (!this.S) {
            String h2 = this.t.h();
            this.i = h2;
            if (!z2) {
                z2 = h2.contains("useX5=1");
            }
            String str = "dbnewopenbackrefresh";
            if (this.i.contains(str)) {
                this.m = true;
            } else {
                str = "dbnewopen";
                if (!this.i.contains(str)) {
                    if (this.i.contains("autoClose=1")) {
                        this.Q = true;
                    }
                }
            }
            this.l = true;
            this.i = this.i.replace(str, "none");
        }
        this.b = (RelativeLayout) layoutInflater.inflate(com.iBookStar.utils.k.a(R.layout.ym_webview_fragment, "ym_webview_fragment", TtmlNode.TAG_LAYOUT), (ViewGroup) null);
        a(z2);
        a();
        int a2 = this.t.a();
        this.v = a2;
        if (a2 > 2) {
            this.v = 2;
        }
        int b2 = this.t.b();
        this.x = b2;
        this.w = Math.round(((((float) b2) * 1000.0f) / 360.0f) + 0.5f);
        if (this.S) {
            this.i = getArguments().getString("url", this.i);
            this.c.setTouchByUser();
            m();
            this.b.post(new a());
        }
        if (!this.i.contains("_needloginbeforemonthpay=1") || com.iBookStar.c.b.j().d()) {
            this.c.loadUrl(this.i);
        } else {
            this.c.login(null, null);
        }
        com.iBookStar.utils.v.k();
        o0 = true;
        return this.b;
    }

    @Override // androidx.fragment.app.Fragment
    public void onDestroy() {
        super.onDestroy();
        Iterator<CoinWebViewFragment> it = n0.iterator();
        while (it.hasNext()) {
            if (it.next() == this) {
                it.remove();
            }
        }
        for (Map.Entry<String, PopupWebView> entry : this.W.entrySet()) {
            entry.getValue().destroyPopupWindow(entry.getKey());
        }
        this.W.clear();
        com.iBookStar.utils.v.j();
    }

    @Override // androidx.fragment.app.Fragment
    public void onDestroyView() {
        super.onDestroyView();
        this.c.unregisterEventBus();
        com.iBookStar.utils.w.a().c(this);
        this.c.finish();
        try {
            ViewParent parent = this.c.getParent();
            if (parent != null) {
                ((ViewGroup) parent).removeView(this.c);
            }
            this.c.stopLoading();
            this.c.setJavaScriptEnabled(false);
            this.c.clearHistory();
            this.c.clearView();
            this.c.removeAllViews();
            this.c.destroy();
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onFloatAdShow() {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onMonitorPhase(String str) {
        if (!this.a.isFinishing() && this.E <= 0 && this.d0) {
            if ("secondJump".equalsIgnoreCase(str)) {
                if (!this.j0 || this.m0.size() < 2) {
                    this.j0 = true;
                    this.m0.add(this.c.getUrl());
                    d(false);
                    com.iBookStar.a.d.a().c(this.I);
                }
            } else if ("interactTouch".equalsIgnoreCase(str)) {
                c(true);
                if (!this.V && com.iBookStar.utils.s.c(this.h0)) {
                    this.e.setExpandDesc(this.h0);
                }
            }
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onMonitorTips(String str) {
        if (!this.a.isFinishing() && this.E <= 0 && this.d0) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                this.e0 = jSONObject.optString("firstJump");
                this.f0 = jSONObject.optString("secondJump");
                this.g0 = jSONObject.optString("interactionDesc");
                this.h0 = jSONObject.optString("thirdJump");
                if (!this.e.isShow()) {
                    if (!this.i0) {
                        this.Z = false;
                        this.X = 0;
                        this.Y = false;
                        this.P = true;
                        this.m0.clear();
                        this.m0.add("xxx.com.cn");
                        this.z = 0.0f;
                        this.B = 0;
                        this.i0 = true;
                        y yVar = this.k;
                        if (yVar != null) {
                            com.iBookStar.a.f fVar = this.I;
                            yVar.a(1, fVar != null ? fVar.o() : 0);
                        }
                    }
                    a(false, true, (String) null, (String) null, 0L, 0L);
                    d(false);
                }
            } catch (Throwable unused) {
            }
        }
    }

    @Override // androidx.fragment.app.Fragment
    public void onPause() {
        super.onPause();
        this.H = true;
        this.c.changeVisibility(8);
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onPayCancel() {
        this.o = false;
        if (!this.p) {
            this.a.setResult(0, this.q);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onPayFinish() {
        this.o = false;
        if (!this.p) {
            this.a.setResult(-1, this.q);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onPayStart() {
        this.o = true;
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onRefresh() {
        this.n = true;
    }

    @Override // androidx.fragment.app.Fragment
    public void onResume() {
        super.onResume();
        this.H = false;
        if (this.X > 0 && this.Y) {
            a(this.t, 1);
            this.G = true;
            n();
            this.X = 0;
            this.Y = false;
            this.Z = false;
        }
        this.c.changeVisibility(0);
        if (o0) {
            h();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void onSkipAd() {
    }

    @Override // androidx.fragment.app.Fragment
    public void onStop() {
        super.onStop();
        if (this.Q) {
            a(this);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void openCouponPage(String str) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void openItemDetailWithParams(String str) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void openNextCoinTask() {
        com.iBookStar.utils.v.a(this.R);
        a(true, false);
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void openURLWithNewWindow(String str) {
        try {
            Intent intent = new Intent(com.iBookStar.b.a.k(), SurveyWebView.class);
            intent.putExtra("url", str);
            intent.putExtra("back", true);
            startActivity(intent);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void postPopupWindowHeight(String str, int i2) {
        PopupWebView a2 = a(str);
        if (a2 != null) {
            a2.postPopupWindowHeight(str, i2);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void postRightBtn(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            String optString = jSONObject.optString("text");
            if (com.iBookStar.utils.s.c(optString)) {
                this.b0 = jSONObject.optString("callback");
                y yVar = this.k;
                if (yVar != null) {
                    yVar.a(optString);
                    this.k.a(1);
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void postTaskCenterCloseMsg(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            this.M = "1".equalsIgnoreCase(jSONObject.optString("sdkback", "1"));
            this.N = jSONObject.optString(CampaignEx.JSON_KEY_TITLE, "完成任务后可领取大礼包");
            jSONObject.optString(CampaignEx.JSON_KEY_DESC, "再次点击小程序退出");
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void postTaskCondition(String str) {
        try {
            if (!this.P && com.iBookStar.utils.s.c(str)) {
                this.y = new JSONObject(str).getJSONObject("condition").optInt("timeout", 10);
            }
        } catch (Exception unused) {
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void sendMessage(String str, String str2) {
        PopupWebView a2 = a(str);
        if (a2 != null) {
            a2.onReceiveMessage(str2);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void setAdItem(com.iBookStar.a.f fVar) {
        this.I = fVar;
        this.J = fVar.b();
        this.f102K = fVar.z();
        if (!com.iBookStar.c.b.a("use_monitor_control", false) && fVar.N() > 0) {
            int N2 = (int) fVar.N();
            this.x = N2;
            this.w = Math.round(((((float) N2) * 1000.0f) / 360.0f) + 0.5f);
            if (Math.random() < fVar.O()) {
                this.v = 2;
            } else {
                this.v = 1;
            }
        }
        if ("buy".equalsIgnoreCase(this.J)) {
            this.L.clear();
            if (!com.iBookStar.utils.s.c(fVar.v())) {
                this.L.add("detail.m.tmall");
                this.L.add("awp/core/detail");
            } else if (fVar.v().equalsIgnoreCase("dzad")) {
                this.d0 = true;
            } else {
                String[] split = fVar.v().split("\\|");
                for (String str : split) {
                    if (com.iBookStar.utils.s.c(str)) {
                        this.L.add(str);
                    }
                }
            }
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void setStatusBarMode(int i2) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void shareGoodsDetails(String str) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void showPopupWindow(String str) {
        PopupWebView a2 = a(str);
        if (a2 != null) {
            a2.showPopupWindow(str);
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void timeMonitorComplete() {
        if (this.E == 0 && this.v > 0 && this.Z) {
            this.Y = true;
            if (!this.H) {
                a(this.t, 1);
                this.G = true;
                n();
                this.Y = false;
                this.X = 0;
                this.Z = false;
            }
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void userToLoginAndAuthorized(String str) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void webPageChanged(String str) {
        if (this.v > 0) {
            s();
        }
        if (this.E > 0) {
            t();
        }
        this.P = false;
        y yVar = this.k;
        if (yVar != null) {
            yVar.a(b() ? 1 : 0, 0);
            this.k.a(1);
            if (com.iBookStar.c.b.a(com.iBookStar.c.c.a("project_valid"), true)) {
                this.k.b(this.h);
            } else {
                this.k.c(this.c.getTitle());
            }
        }
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void webviewTitleChangeToString(String str) {
    }

    @Override // com.iBookStar.views.CommonWebView.g2
    public void withdraw() {
        try {
            String format = String.format("http://rp.ipadview.com/alipay/account/transferpage?bpid=%s&buid=%s", com.iBookStar.b.a.j, String.valueOf(com.iBookStar.c.b.j().c()));
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(Uri.parse(String.format("alipays://platformapi/startapp?appId=20000067&url=%s", URLEncoder.encode(format))));
            startActivity(intent);
        } catch (Exception unused) {
            Toast.makeText(this.a, "没有安装支付宝或者不是最新版", 0).show();
        }
        o0 = true;
    }
}