导航菜单

页面标题

页面副标题

Spermatid Pro v6.4.3 - AdViewImpl.java 源代码

正在查看: Spermatid Pro v6.4.3 应用的 AdViewImpl.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.octopus.ad.internal.view;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.MutableContextWrapper;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import com.octopus.ad.AdActivity;
import com.octopus.ad.AdLifeControl;
import com.octopus.ad.AppEventListener;
import com.octopus.ad.FullScreenVideoAdListener;
import com.octopus.ad.IBidding;
import com.octopus.ad.InterstitialAdListener;
import com.octopus.ad.Octopus;
import com.octopus.ad.OnSensorListener;
import com.octopus.ad.R;
import com.octopus.ad.RewardVideoAdListener;
import com.octopus.ad.SplashAdListener;
import com.octopus.ad.internal.a;
import com.octopus.ad.internal.a.b;
import com.octopus.ad.internal.a.h;
import com.octopus.ad.internal.d;
import com.octopus.ad.internal.l;
import com.octopus.ad.internal.m;
import com.octopus.ad.internal.network.ServerResponse;
import com.octopus.ad.internal.network.a;
import com.octopus.ad.internal.p;
import com.octopus.ad.internal.r;
import com.octopus.ad.internal.utilities.HTTPGet;
import com.octopus.ad.internal.utilities.HaoboLog;
import com.octopus.ad.internal.utilities.StringUtil;
import com.octopus.ad.internal.utilities.UrlUtil;
import com.octopus.ad.internal.utilities.ViewUtil;
import com.octopus.ad.internal.video.AdVideoView;
import com.octopus.ad.internal.view.AdWebView;
import com.octopus.ad.internal.view.f;
import com.octopus.ad.model.ComplianceInfo;
import com.octopus.ad.model.c;
import com.octopus.ad.utils.b.g;
import com.octopus.ad.utils.i;
import com.octopus.ad.utils.j;
import com.octopus.ad.utils.k;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public abstract class AdViewImpl extends FrameLayout implements ViewTreeObserver.OnGlobalLayoutListener, AdLifeControl, IBidding, a {
    private static FrameLayout aT;
    private static f aU;
    private static AdWebView.b aV;
    private int A;
    private int B;
    private float C;
    private String D;
    private SplashAdListener E;
    private InterstitialAdListener F;
    private FullScreenVideoAdListener G;
    private RewardVideoAdListener H;
    private AppEventListener I;
    private d J;
    private com.octopus.ad.model.a K;
    private final Handler L;
    private b M;
    private b N;
    private h O;
    private boolean P;
    private boolean Q;
    private boolean R;
    private boolean S;
    private boolean T;
    private boolean U;
    private AppCompatTextView V;
    private AppCompatTextView W;
    public boolean a;
    private boolean aA;
    private int aB;
    private AdVideoView aC;
    private AdWebView aD;
    private boolean aE;
    private boolean aF;
    private boolean aG;
    private ViewGroup aH;
    private String aI;
    private String aJ;
    private Pair<String, Integer> aK;
    private boolean aL;
    private boolean aM;
    private int aN;
    private k aO;
    private j aP;
    private i aQ;
    private OnSensorListener aR;
    private final c aS;
    private boolean aW;
    private AppCompatTextView aa;

    private ImageView f1773ab;
    private com.octopus.ad.a.a ac;

    private AppCompatImageView f1774ad;
    private AppCompatTextView ae;
    private ProgressBar af;
    private FrameLayout ag;
    private FrameLayout ah;
    private int ai;
    private String aj;
    private String ak;
    private String al;
    private String am;
    private String an;
    private int ao;
    private int ap;
    private int aq;
    private long ar;
    private long as;
    private boolean at;
    private boolean au;
    private boolean av;
    private boolean aw;
    private boolean ax;
    private boolean ay;
    private Boolean az;
    public ServerResponse b;
    public a c;
    public c d;
    public boolean e;

    public boolean f1775f;
    public boolean g;

    public boolean f1776h;

    public d f1777i;
    public a.a j;
    public com.octopus.ad.internal.c k;
    public l l;

    public boolean f1778m;

    public int f1779n;
    public int o;
    public int p;

    public int f1780q;

    public int f1781r;
    public int s;
    public boolean t;
    public boolean u;
    public boolean v;

    public boolean f1782w;
    public Activity x;

    public int f1783y;

    private ViewGroup f1784z;

    public AdViewImpl(Context context) {
        this(context, (AttributeSet) null, 0);
    }

    public static int G(AdViewImpl adViewImpl) {
        int i3 = adViewImpl.aN;
        adViewImpl.aN = i3 - 1;
        return i3;
    }

    public static FrameLayout getMRAIDFullscreenContainer() {
        return aT;
    }

    public static f getMRAIDFullscreenImplementation() {
        return aU;
    }

    public static AdWebView.b getMRAIDFullscreenListener() {
        return aV;
    }

    private com.octopus.ad.model.d getRandomClickPosition() {
        int screenWidth;
        int screenHeight;
        try {
            if (!this.ax && !this.ay) {
                AdWebView adWebView = this.aC;
                if (adWebView == null) {
                    adWebView = this.aD;
                }
                screenWidth = 0;
                if (adWebView != null) {
                    screenWidth = adWebView.getWidth();
                    screenHeight = adWebView.getHeight();
                } else {
                    screenHeight = 0;
                }
                if (screenWidth == 0 || screenHeight == 0) {
                    screenWidth = ViewUtil.getScreenWidth(getContext());
                    screenHeight = ViewUtil.getScreenWidth(getContext());
                }
                int a = com.octopus.ad.utils.h.a(screenWidth);
                int a2 = com.octopus.ad.utils.h.a(screenHeight);
                int a3 = com.octopus.ad.utils.h.a(150) + 50;
                com.octopus.ad.model.d dVar = new com.octopus.ad.model.d(1);
                float f2 = a;
                dVar.a(f2);
                float f5 = a2;
                dVar.b(f5);
                dVar.a(String.valueOf(System.currentTimeMillis()));
                dVar.c(f2);
                dVar.d(f5);
                dVar.b(String.valueOf(System.currentTimeMillis() + a3));
                dVar.a(screenWidth);
                dVar.b(screenHeight);
                return dVar;
            }
            screenWidth = ViewUtil.getScreenWidth(getContext());
            screenHeight = ViewUtil.getScreenHeight(getContext());
            int a4 = com.octopus.ad.utils.h.a(screenWidth);
            int a22 = com.octopus.ad.utils.h.a(screenHeight);
            int a32 = com.octopus.ad.utils.h.a(150) + 50;
            com.octopus.ad.model.d dVar2 = new com.octopus.ad.model.d(1);
            float f22 = a4;
            dVar2.a(f22);
            float f52 = a22;
            dVar2.b(f52);
            dVar2.a(String.valueOf(System.currentTimeMillis()));
            dVar2.c(f22);
            dVar2.d(f52);
            dVar2.b(String.valueOf(System.currentTimeMillis() + a32));
            dVar2.a(screenWidth);
            dVar2.b(screenHeight);
            return dVar2;
        } catch (Exception e) {
            g.a("OctopusAd", "An Exception Caught", e);
            return null;
        }
    }

    public static void setMRAIDFullscreenContainer(FrameLayout frameLayout) {
        aT = frameLayout;
    }

    public static void setMRAIDFullscreenImplementation(f fVar) {
        aU = fVar;
    }

    public static void setMRAIDFullscreenListener(AdWebView.b bVar) {
        aV = bVar;
    }

    public void a(Activity activity) {
    }

    public abstract boolean a(c cVar);

    public abstract void b(Context context, AttributeSet attributeSet);

    @Override
    public void cancel() {
        destroy();
    }

    @Override
    public void destroy() {
        HaoboLog.d(HaoboLog.baseLogTag, "called destroy() on AdView");
        this.ag = null;
        this.f1773ab = null;
        this.ah = null;
        this.aC = null;
        this.ae = null;
        this.af = null;
        this.f1774ad = null;
        this.V = null;
        this.aa = null;
        ServerResponse serverResponse = this.b;
        if (serverResponse != null) {
            serverResponse.ac();
        }
        com.octopus.ad.internal.c cVar = this.k;
        if (cVar != null) {
            cVar.b();
            this.k.a();
            this.k = null;
        }
        c cVar2 = this.d;
        if (cVar2 != null) {
            cVar2.destroy();
            this.d = null;
        }
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        return super.dispatchTouchEvent(motionEvent);
    }

    public void finalize() {
        try {
            super.finalize();
        } catch (Throwable th) {
            g.a("OctopusAd", "A Throwable Caught", th);
        }
        com.octopus.ad.internal.c cVar = this.k;
        if (cVar != null) {
            cVar.a();
        }
    }

    public com.octopus.ad.internal.b getAdDispatcher() {
        return this.M;
    }

    public String getAdId() {
        return this.al;
    }

    public d getAdParameters() {
        return this.f1777i;
    }

    public a.a getAdRequest() {
        return this.j;
    }

    public com.octopus.ad.b getAdSize() {
        return new com.octopus.ad.b(this.A, this.B);
    }

    public String getAdSlotId() {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.get_placement_id, this.f1777i.c()));
        d dVar = this.f1777i;
        return dVar == null ? "" : dVar.c();
    }

    public AppEventListener getAppEventListener() {
        return this.I;
    }

    public d getBrowserStyle() {
        return this.J;
    }

    public int getContainerHeight() {
        return this.f1777i.l();
    }

    public int getContainerWidth() {
        return this.f1777i.k();
    }

    public int getCreativeHeight() {
        return this.B;
    }

    public int getCreativeWidth() {
        return this.A;
    }

    public String getExtraData() {
        return this.am;
    }

    public String getLandingPageUrl() {
        return this.ak;
    }

    public boolean getLoadsInBackground() {
        return this.f1776h;
    }

    public Map<String, Object> getMediaExtraInfo() {
        ServerResponse serverResponse = this.b;
        return serverResponse != null ? serverResponse.T() : Collections.emptyMap();
    }

    public String getMediationAdapterClassName() {
        return null;
    }

    public Handler getMyHandler() {
        return this.L;
    }

    public boolean getOpensNativeBrowser() {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.get_opens_native_browser, this.f1777i.m()));
        return this.f1777i.m();
    }

    public int getPrice() {
        return this.ai;
    }

    public String getRequestId() {
        d dVar = this.f1777i;
        return (dVar == null || TextUtils.isEmpty(dVar.f())) ? this.aI : this.f1777i.f();
    }

    public RewardVideoAdListener getRewaredVideoAdListener() {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.get_reward_video_ad_listener));
        return this.H;
    }

    public boolean getShowLoadingIndicator() {
        return this.Q;
    }

    public ViewGroup getSplashParent() {
        return this.f1784z;
    }

    public String getTagId() {
        return this.aj;
    }

    public String getUserId() {
        return this.an;
    }

    public abstract boolean j();

    public abstract boolean k();

    @Override
    public void onCreateLifeCycle() {
    }

    @Override
    public void onDestroyLifeCycle() {
        com.octopus.ad.internal.c cVar = this.k;
        if (cVar != null) {
            cVar.a();
        }
        B();
        C();
        p();
    }

    @Override
    public void onGlobalLayout() {
        c.o I;
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        adWebView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        ServerResponse serverResponse = this.b;
        if (serverResponse == null || (I = serverResponse.I()) == null) {
            return;
        }
        c.m a = I.a();
        if (a != null) {
            e(a.a() == 1);
        } else if (this.a || c()) {
            e(false);
        }
        c.u c = I.c();
        if (c != null && c.a() == 1) {
            a(c);
        }
        c.s d = I.d();
        if (d != null && d.a() == 1) {
            a(d.b());
        }
        c.r b = I.b();
        if (b == null || b.a() != 1) {
            return;
        }
        b(b.b());
    }

    @Override
    public void onLayout(boolean z4, int i3, int i4, int i5, int i6) {
        super.onLayout(z4, i3, i4, i5, i6);
    }

    @Override
    public void onPauseLifeCycle() {
    }

    @Override
    public void onRestartLifeCycle() {
    }

    @Override
    public void onResumeLifeCycle() {
        a aVar = this.c;
        a.a aVar2 = a.a.d;
        aVar.a(aVar2);
        if (this.c.c() == aVar2) {
            getAdDispatcher().a();
        }
        if (this.aE && this.av && getMediaType() == l.c) {
            y();
        }
    }

    @Override
    public void onStartLifeCycle() {
    }

    @Override
    public void onStopLifeCycle() {
        this.c.a(a.a.c);
    }

    public abstract void p();

    public abstract void q();

    public abstract void r();

    public abstract void s();

    public void sendLossNotice(int i3, String str, String str2) {
        try {
            this.b.a(i3, str, str2);
            t();
        } catch (Throwable th) {
            g.a("OctopusAd", "A Throwable Caught", th);
        }
    }

    public void sendWinNotice(int i3) {
        try {
            this.b.a(i3);
        } catch (Throwable th) {
            g.a("OctopusAd", "A Throwable Caught", th);
        }
    }

    public void setAdExtInfo(String str) {
        this.D = str;
    }

    public void setAdId(String str) {
        this.al = str;
    }

    public void setAdSlotId(String str) {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.set_placement_id, str));
        d dVar = this.f1777i;
        if (dVar != null) {
            dVar.a(str);
        }
    }

    public void setAdVideoView(AdVideoView adVideoView) {
        this.aC = adVideoView;
    }

    public void setAdWebView(AdWebView adWebView) {
        this.aD = adWebView;
    }

    public void setAppEventListener(AppEventListener appEventListener) {
        this.I = appEventListener;
    }

    public void setBrowserStyle(d dVar) {
        this.J = dVar;
    }

    public void setChannel(String str) {
        d dVar = this.f1777i;
        if (dVar != null) {
            dVar.b(str);
        }
    }

    public void setClickBackClose(boolean z4) {
        this.aE = z4;
    }

    public void setCountDownTime(int i3) {
        this.aq = i3;
    }

    public void setCreativeHeight(int i3) {
        this.B = i3;
    }

    public void setCreativeWidth(int i3) {
        this.A = i3;
        float f2 = i3 > 0 ? i3 / 640.0f : 1.0f;
        this.C = f2;
        if (f2 > 1.0f) {
            this.C = 1.0f;
        }
    }

    public void setExtraData(String str) {
        this.am = str;
    }

    public void setFullScreenVideoAdListener(FullScreenVideoAdListener fullScreenVideoAdListener) {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.set_full_screen_video_ad_listener));
        this.G = fullScreenVideoAdListener;
    }

    public void setInterstitialAdListener(InterstitialAdListener interstitialAdListener) {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.set_interstitial_ad_listener));
        this.F = interstitialAdListener;
    }

    public void setIsBoost(boolean z4) {
        this.f1777i.b(z4);
    }

    public void setIsClicked(boolean z4) {
        this.av = z4;
    }

    public void setLandingPageUrl(String str) {
        this.ak = str;
    }

    public void setLoadsInBackground(boolean z4) {
        this.f1776h = z4;
    }

    public void setOnSensorListener(OnSensorListener onSensorListener) {
        this.aR = onSensorListener;
    }

    public void setOpensNativeBrowser(boolean z4) {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.set_opens_native_browser, z4));
        this.f1777i.c(z4);
    }

    public void setPrice(int i3) {
        this.ai = i3;
    }

    public void setRequestId(String str) {
        d dVar = this.f1777i;
        if (dVar != null) {
            dVar.c(str);
        }
    }

    public void setRewardVideoAdListener(RewardVideoAdListener rewardVideoAdListener) {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.set_reward_video_ad_listener));
        this.H = rewardVideoAdListener;
    }

    public void setScrollClick(View.OnTouchListener onTouchListener) {
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        adWebView.setOnTouchListener(onTouchListener);
    }

    public void setShouldResizeParent(boolean z4) {
        this.P = z4;
    }

    public void setShowLoadingIndicator(boolean z4) {
        this.Q = z4;
    }

    public void setSplashAdListener(SplashAdListener splashAdListener) {
        HaoboLog.d(HaoboLog.publicFunctionsLogTag, HaoboLog.getString(R.string.set_splash_ad_listener));
        this.E = splashAdListener;
    }

    public void setTagId(String str) {
        this.aj = str;
    }

    public void setUserId(String str) {
        this.an = str;
    }

    public void setValidTime(long j) {
        m.s = j;
        this.as = j;
    }

    public AdViewImpl(Context context, ViewGroup viewGroup, View view) {
        super(context, null, 0);
        this.D = "";
        this.c = new a();
        this.L = new 1(this, Looper.getMainLooper());
        this.e = false;
        this.f1775f = false;
        this.g = false;
        this.f1776h = true;
        this.P = false;
        this.Q = true;
        this.f1777i = null;
        this.j = null;
        this.R = false;
        this.f1778m = false;
        this.U = false;
        this.ao = 0;
        this.ap = 0;
        this.aB = 0;
        this.aF = false;
        this.aG = false;
        this.t = false;
        this.u = false;
        this.v = false;
        this.f1782w = false;
        this.aK = null;
        this.aL = false;
        this.aM = false;
        this.aN = 2;
        this.aS = new 28(this);
        this.f1783y = 0;
        this.aW = false;
        this.a = true;
        this.f1784z = viewGroup;
        a(context, (AttributeSet) null);
    }

    public void A() {
        AdVideoView adVideoView = this.aC;
        if (adVideoView == null) {
            return;
        }
        String videoUrl = adVideoView.getVideoUrl();
        if (TextUtils.isEmpty(videoUrl)) {
            b(false);
            return;
        }
        ServerResponse serverResponse = this.b;
        if (serverResponse != null && (!serverResponse.v() || "m3u8".equalsIgnoreCase(this.b.e()))) {
            b(true);
            return;
        }
        h b = m.a().b();
        this.O = b;
        if (b == null) {
            b(false);
            return;
        }
        if (b.b(videoUrl)) {
            b(true);
            return;
        }
        b bVar = new 16(this);
        this.N = bVar;
        this.O.a(bVar, videoUrl);
        ServerResponse serverResponse2 = this.b;
        if (serverResponse2 != null) {
            serverResponse2.a(new 17(this));
        }
    }

    private void B() {
        b bVar;
        h hVar = this.O;
        if (hVar == null || (bVar = this.N) == null) {
            return;
        }
        hVar.a(bVar);
    }

    private void C() {
        k kVar = this.aO;
        if (kVar != null) {
            kVar.a();
            this.aO = null;
        }
        i iVar = this.aQ;
        if (iVar != null) {
            iVar.a();
        }
        j jVar = this.aP;
        if (jVar != null) {
            jVar.b();
        }
    }

    public void t() {
        ServerResponse serverResponse;
        c.w J;
        c.p c;
        ServerResponse serverResponse2;
        if (this.ax || (serverResponse = this.b) == null || (J = serverResponse.J()) == null || (c = J.c()) == null) {
            return;
        }
        if (c.a() == 1) {
            this.ax = true;
            AdWebView adWebView = this.aD;
            if (adWebView != null && (serverResponse2 = adWebView.b) != null) {
                serverResponse2.b(true);
            }
            new Handler().postDelayed(new 29(this), c.c());
            if (c.b() == 1) {
                new Handler().postDelayed(new 30(this), c.d());
            }
        }
    }

    public void u() {
        c.w J;
        c.p c;
        ServerResponse serverResponse;
        ServerResponse serverResponse2 = this.b;
        if (serverResponse2 == null || (J = serverResponse2.J()) == null || (c = J.c()) == null) {
            return;
        }
        if (c.a() == 1) {
            AdWebView adWebView = this.aD;
            if (adWebView != null && (serverResponse = adWebView.b) != null) {
                serverResponse.c(true);
            }
            new Handler().postDelayed(new 31(this), c.c());
            if (c.b() == 1) {
                new Handler().postDelayed(new 32(this), c.d());
            }
        }
    }

    public void v() {
        ServerResponse serverResponse;
        if (this.aD == null || (serverResponse = this.b) == null) {
            return;
        }
        if (a(serverResponse)) {
            this.aw = false;
            this.aB = 0;
        } else {
            this.aw = true;
            this.aB = 9;
        }
        this.aD.a(this.aB, getRandomClickPosition());
    }

    public void w() {
        if (!this.at || this.av) {
            y();
            return;
        }
        this.aB = 2;
        AdVideoView adVideoView = this.aC;
        if (adVideoView != null) {
            adVideoView.setOpt(2);
        }
        a(getRandomClickPosition());
    }

    public void x() {
        ServerResponse serverResponse;
        AdWebView adWebView = this.aD;
        if (adWebView == null || (serverResponse = adWebView.b) == null) {
            return;
        }
        serverResponse.a(adWebView, e(), (com.octopus.ad.a) null);
    }

    public void y() {
        if (getAdDispatcher() != null) {
            getAdDispatcher().a();
        }
        com.octopus.ad.a.a aVar = this.ac;
        if (aVar != null) {
            aVar.d();
        }
        Activity b = b((View) this.aD);
        if (!k() || b == null || b.isFinishing() || !(b instanceof AdActivity)) {
            return;
        }
        b.finish();
    }

    private void z() {
        c.l f2;
        if (this.b == null || !m.a().e() || (f2 = this.b.f()) == null || TextUtils.isEmpty(f2.c())) {
            return;
        }
        m.a().d();
        if (f2.b() == 1) {
            this.K = (com.octopus.ad.model.a) m.a().g.get(f2.c());
        }
        com.octopus.ad.model.a aVar = this.K;
        if (aVar == null || !aVar.j() || this.K.g() < getPrice()) {
            com.octopus.ad.model.a aVar2 = new com.octopus.ad.model.a();
            this.K = aVar2;
            aVar2.a(getPrice());
            this.K.a(this.ar);
            this.K.b(this.as);
            this.K.a(getRequestId());
            this.K.b(f2.a());
            this.K.b(f2.c());
            this.K.c(f2.d());
            this.K.a(this.b.Q());
            this.K.e(this.b.S());
            ServerResponse serverResponse = this.b;
            if (serverResponse != null && serverResponse.a() != null) {
                this.K.d(this.b.R());
                this.K.a(this.b.a().s());
            }
            m.a().g.put(f2.c(), this.K);
        }
    }

    public void h() {
        ProgressBar progressBar = this.af;
        if (progressBar != null) {
            progressBar.setVisibility(8);
        }
    }

    public boolean i() {
        return this.R;
    }

    public void l() {
        if (this.aF) {
            return;
        }
        this.aF = true;
        this.ar = System.currentTimeMillis();
        SplashAdListener splashAdListener = this.E;
        if (splashAdListener != null) {
            splashAdListener.onAdLoaded();
        } else {
            InterstitialAdListener interstitialAdListener = this.F;
            if (interstitialAdListener != null) {
                interstitialAdListener.onAdLoaded();
            } else {
                FullScreenVideoAdListener fullScreenVideoAdListener = this.G;
                if (fullScreenVideoAdListener != null) {
                    fullScreenVideoAdListener.onAdLoaded();
                } else {
                    RewardVideoAdListener rewardVideoAdListener = this.H;
                    if (rewardVideoAdListener != null) {
                        rewardVideoAdListener.onRewardVideoAdLoaded();
                    }
                }
            }
        }
        z();
    }

    public void m() {
        RewardVideoAdListener rewardVideoAdListener;
        if (this.aM || !this.T || (rewardVideoAdListener = this.H) == null) {
            return;
        }
        this.aM = true;
        rewardVideoAdListener.onRewardVideoAdComplete();
    }

    public void n() {
        if (this.aL || this.aK == null) {
            return;
        }
        this.aL = true;
        AppCompatTextView appCompatTextView = this.V;
        if (appCompatTextView != null) {
            appCompatTextView.setText("恭喜获得奖励");
        }
        if (!TextUtils.isEmpty(this.aJ)) {
            o();
        } else {
            Pair<String, Integer> pair = this.aK;
            a((String) pair.first, ((Integer) pair.second).intValue());
        }
    }

    public void o() {
        new p(this.aJ).a(new HTTPGet.ResponseListener() {
            public void getResponse(boolean z4, String str) {
                if (z4 && !TextUtils.isEmpty(str)) {
                    try {
                        if (new JSONObject(str).optBoolean("isValid") && AdViewImpl.this.aK != null) {
                            AdViewImpl adViewImpl = AdViewImpl.this;
                            adViewImpl.a((String) adViewImpl.aK.first, ((Integer) AdViewImpl.this.aK.second).intValue());
                        }
                    } catch (Exception e) {
                        g.a("OctopusAd", "An Exception Caught", e);
                    }
                } else if (AdViewImpl.this.aN > 0) {
                    new Handler().postDelayed(new 1(this), 200L);
                }
                if (z4 || AdViewImpl.this.aN == 0) {
                    AdViewImpl.this.d(z4);
                }
            }
        }).execute();
    }

    public boolean b() {
        return this.f1775f;
    }

    public boolean c() {
        return l.e == this.l;
    }

    public boolean d() {
        return this.aF;
    }

    public boolean e() {
        long currentTimeMillis;
        long j;
        d dVar = this.f1777i;
        if (dVar != null && dVar.g() > 0) {
            currentTimeMillis = System.currentTimeMillis();
            j = this.f1777i.g();
        } else {
            currentTimeMillis = System.currentTimeMillis();
            j = this.ar;
        }
        return currentTimeMillis - j < this.as;
    }

    public void f() {
        getVisibility();
    }

    public void g() {
        getVisibility();
    }

    public Activity b(View view) {
        return (Activity) a(view);
    }

    public void c(View view) {
        ViewUtil.removeChildFromParent(this.ag);
        ViewUtil.removeChildFromParent(this.ah);
        ViewParent parent = k() ? view.getParent() : this;
        if (parent instanceof FrameLayout) {
            if (this.ag != null) {
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, 42, 83);
                layoutParams.setMargins(30, 0, 0, 50);
                ((FrameLayout) parent).addView(this.ag, layoutParams);
                this.ag.setVisibility(0);
            }
            if (this.ah != null) {
                FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-1, 42, 85);
                layoutParams2.setMargins(0, 0, 30, 50);
                ((FrameLayout) parent).addView(this.ah, layoutParams2);
                this.ah.setVisibility(0);
            }
        }
    }

    public void d(View view) {
        ViewUtil.removeChildFromParent(this.aa);
        this.f1780q = getMediaType() == l.c ? 10 : 30;
        this.p = this.aC == null ? 0 : 30;
        this.aa = ViewUtil.createFeedBackButton(getContext(), UrlUtil.replaceFeedBackUrl("https://www.adintl.cn/sdkFeedback.html?slotId=${SLOT_ID}&sdkVersion=${SDK_VERSION}&deviceId=${DEVICE_ID}", getAdSlotId(), Octopus.getOaid(getContext())), this.p, this.f1780q, this.C);
        ViewParent parent = k() ? view.getParent() : this;
        if (parent instanceof FrameLayout) {
            ((FrameLayout) parent).addView(this.aa);
        }
    }

    public void b(int i3) {
        if (this.aW) {
            return;
        }
        SplashAdListener splashAdListener = this.E;
        if (splashAdListener != null) {
            splashAdListener.onAdFailedToLoad(i3);
        } else {
            InterstitialAdListener interstitialAdListener = this.F;
            if (interstitialAdListener != null) {
                interstitialAdListener.onAdFailedToLoad(i3);
            } else {
                FullScreenVideoAdListener fullScreenVideoAdListener = this.G;
                if (fullScreenVideoAdListener != null) {
                    fullScreenVideoAdListener.onAdFailedToLoad(i3);
                } else {
                    RewardVideoAdListener rewardVideoAdListener = this.H;
                    if (rewardVideoAdListener != null) {
                        rewardVideoAdListener.onRewardVideoAdFailedToLoad(i3);
                    }
                }
            }
        }
        this.aW = true;
    }

    public void a(int i3, int i4, int i5, int i6) {
        this.p = i3;
        this.f1780q = i4;
        this.f1781r = i5;
        this.s = i6;
    }

    public void e(View view) {
        int screenWidth;
        AppCompatTextView appCompatTextView = this.ae;
        if (appCompatTextView != null) {
            ViewUtil.removeChildFromParent(appCompatTextView);
            ViewParent parent = k() ? view.getParent() : this;
            if (parent instanceof FrameLayout) {
                int i3 = -1;
                ServerResponse serverResponse = this.b;
                if (serverResponse != null) {
                    int k = serverResponse.k();
                    if (getMediaType().equals(l.c) && k > 0 && (i3 = (int) (k * m.a().o)) > (screenWidth = ViewUtil.getScreenWidth(getContext()))) {
                        i3 = screenWidth;
                    }
                }
                ((FrameLayout) parent).addView((View) this.ae, (ViewGroup.LayoutParams) new FrameLayout.LayoutParams(i3, -2, 80));
            }
        }
    }

    public void a(Context context, AttributeSet attributeSet) {
        g.c("OctopusAd_Time", "AdViewImpl setup 开始 mRequestId : " + this.aI);
        setBackgroundColor(0);
        this.M = new b(this, this.L);
        this.aI = StringUtil.createRequestId();
        this.f1777i = new d(context, this.aI);
        try {
            HaoboLog.setErrorContext(getContext().getApplicationContext());
        } catch (Exception e) {
            g.a("OctopusAd", "An Exception Caught", e);
        }
        setPadding(0, 0, 0, 0);
        this.k = new com.octopus.ad.internal.c(this);
        if (attributeSet != null) {
            b(context, attributeSet);
        }
        this.aO = new k(getContext());
        this.aP = new j(getContext());
        this.aQ = new i(getContext());
    }

    public void d(boolean z4) {
        new Thread((Runnable) new 19(this, z4)).start();
    }

    public void b(boolean z4) {
        ServerResponse serverResponse;
        if (this.t || (serverResponse = this.b) == null || serverResponse.m() != 0) {
            return;
        }
        this.t = true;
        SplashAdListener splashAdListener = this.E;
        if (splashAdListener != null) {
            splashAdListener.onAdCacheLoaded(z4);
        } else {
            InterstitialAdListener interstitialAdListener = this.F;
            if (interstitialAdListener != null) {
                interstitialAdListener.onAdCacheLoaded(z4);
            } else {
                FullScreenVideoAdListener fullScreenVideoAdListener = this.G;
                if (fullScreenVideoAdListener != null) {
                    fullScreenVideoAdListener.onAdCacheLoaded(z4);
                } else {
                    RewardVideoAdListener rewardVideoAdListener = this.H;
                    if (rewardVideoAdListener != null) {
                        rewardVideoAdListener.onRewardVideoCached(z4);
                    }
                }
            }
        }
        if (this.v) {
            if (this.l == l.a) {
                a(this.aH);
            } else {
                a(this.x);
            }
        }
    }

    private void e(boolean z4) {
        g.a("OctopusAd", "octopus clickable = " + z4);
        if (z4) {
            return;
        }
        a((View.OnTouchListener) new 22(this));
    }

    public void c(boolean z4) {
        setOpensNativeBrowser(z4);
    }

    public boolean a() {
        if (b()) {
            HaoboLog.e(HaoboLog.baseLogTag, HaoboLog.getString(R.string.already_expanded));
            return false;
        }
        d dVar = this.f1777i;
        return (dVar == null || !dVar.o() || this.j == null) ? false : true;
    }

    public void a(AdWebView adWebView) {
        this.aD = adWebView;
        if (this.aC == null) {
            b(true);
        }
    }

    private void b(String str) {
        View a;
        i iVar = this.aQ;
        if (iVar != null) {
            AdWebView adWebView = this.aC;
            if (adWebView == null) {
                adWebView = this.aD;
            }
            if (adWebView == null || (a = iVar.a(ViewUtil.px2dip(getContext(), adWebView.getWidth()), ViewUtil.px2dip(getContext(), adWebView.getHeight()), str, true)) == null) {
                return;
            }
            a.setOnTouchListener(new 25(this, new com.octopus.ad.model.d(1)));
            ViewParent parent = k() ? adWebView.getParent() : this;
            if (parent instanceof FrameLayout) {
                ((FrameLayout) parent).addView(a);
            }
        }
    }

    public void a(ViewGroup viewGroup) {
        if ((this.u && !this.t) || !this.f1782w) {
            this.v = true;
            this.aH = viewGroup;
            return;
        }
        if (this.aG) {
            return;
        }
        this.aG = true;
        AdVideoView adVideoView = this.aC;
        if (adVideoView != null) {
            adVideoView.h();
        }
        ViewUtil.removeChildFromParent(this);
        if (viewGroup != null) {
            this.f1784z = viewGroup;
        }
        ViewGroup viewGroup2 = this.f1784z;
        if (viewGroup2 != null) {
            viewGroup2.removeAllViews();
            this.f1784z.addView(this, new ViewGroup.LayoutParams(-1, -1));
        }
        a(0, 30, 0, 0);
        int i3 = this.aq;
        if (i3 < 3) {
            i3 = this.aD.getAutoCloseTime();
        }
        a(i3);
        a(this.b, this.aS);
        this.aA = this.b.O();
        this.at = this.b.P();
        this.az = this.b.N();
        if (this.E != null) {
            Log.e("OctopusAd", "enter Octopus ad show");
            AdWebView adWebView = this.aD;
            adWebView.b.a(adWebView, e(), new 12(this));
        }
    }

    public AdViewImpl(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public AdViewImpl(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        this.D = "";
        this.c = new a();
        this.L = new 1(this, Looper.getMainLooper());
        this.e = false;
        this.f1775f = false;
        this.g = false;
        this.f1776h = true;
        this.P = false;
        this.Q = true;
        this.f1777i = null;
        this.j = null;
        this.R = false;
        this.f1778m = false;
        this.U = false;
        this.ao = 0;
        this.ap = 0;
        this.aB = 0;
        this.aF = false;
        this.aG = false;
        this.t = false;
        this.u = false;
        this.v = false;
        this.f1782w = false;
        this.aK = null;
        this.aL = false;
        this.aM = false;
        this.aN = 2;
        this.aS = new 28(this);
        this.f1783y = 0;
        this.aW = false;
        a(context, attributeSet);
    }

    public void a(boolean z4) {
        ServerResponse serverResponse;
        if (this.S) {
            return;
        }
        this.S = true;
        this.T = z4;
        if (z4 && (serverResponse = this.b) != null) {
            this.T = serverResponse.M();
        }
        if (this.T) {
            SplashAdListener splashAdListener = this.E;
            if (splashAdListener != null) {
                splashAdListener.onAdShown();
            } else {
                InterstitialAdListener interstitialAdListener = this.F;
                if (interstitialAdListener != null) {
                    interstitialAdListener.onAdShown();
                } else {
                    FullScreenVideoAdListener fullScreenVideoAdListener = this.G;
                    if (fullScreenVideoAdListener != null) {
                        fullScreenVideoAdListener.onAdShown();
                    } else {
                        RewardVideoAdListener rewardVideoAdListener = this.H;
                        if (rewardVideoAdListener != null) {
                            rewardVideoAdListener.onRewardVideoAdShown();
                        }
                    }
                }
            }
        }
        if (this.K == null || !getRequestId().equals(this.K.a())) {
            return;
        }
        m.a().g.remove(this.K.b());
    }

    public static void a(ServerResponse serverResponse, c cVar) {
        c.w J;
        c.g a;
        if (serverResponse == null || (J = serverResponse.J()) == null || (a = J.a()) == null) {
            return;
        }
        if (a.a() == 1) {
            com.octopus.ad.utils.d.a(new 23(cVar), a.b());
        }
    }

    public static boolean a(ServerResponse serverResponse) {
        c.w J;
        c.g a;
        return (serverResponse == null || (J = serverResponse.J()) == null || (a = J.a()) == null || a.c() != 1) ? false : true;
    }

    public void a(com.octopus.ad.model.d dVar) {
        AdWebView adWebView = this.aD;
        if (adWebView != null) {
            adWebView.a(this.aB, dVar);
        }
    }

    public boolean a(a.a aVar) {
        com.octopus.ad.internal.c cVar;
        this.j = aVar;
        if (!a()) {
            SplashAdListener splashAdListener = this.E;
            if (splashAdListener != null) {
                splashAdListener.onAdFailedToLoad(80000);
            } else {
                InterstitialAdListener interstitialAdListener = this.F;
                if (interstitialAdListener != null) {
                    interstitialAdListener.onAdFailedToLoad(80000);
                } else {
                    FullScreenVideoAdListener fullScreenVideoAdListener = this.G;
                    if (fullScreenVideoAdListener != null) {
                        fullScreenVideoAdListener.onAdFailedToLoad(80000);
                    }
                }
            }
            return false;
        }
        if (getWindowVisibility() == 0 && (cVar = this.k) != null) {
            cVar.a();
            this.k.d();
            this.k.c();
            this.R = true;
            this.f1779n = 1;
            this.o = 0;
            return true;
        }
        com.octopus.ad.internal.c cVar2 = this.k;
        if (cVar2 != null) {
            cVar2.a();
            this.k.d();
            this.k.c();
            this.R = true;
            this.f1779n = 1;
            this.o = 0;
        }
        return false;
    }

    public Context a(View view) {
        Context context;
        if (view == null) {
            return null;
        }
        if (view.getContext() instanceof MutableContextWrapper) {
            context = ((MutableContextWrapper) view.getContext()).getBaseContext();
        } else {
            context = getContext();
        }
        if (context instanceof Activity) {
            return context;
        }
        return null;
    }

    public void a(boolean z4, ServerResponse.AdLogoInfo adLogoInfo, ServerResponse.AdLogoInfo adLogoInfo2, int i3) {
        ViewUtil.removeChildFromParent(this.ag);
        ViewUtil.removeChildFromParent(this.ah);
        float f2 = i3 > 0 ? i3 / 640.0f : 1.0f;
        float f5 = f2 <= 1.0f ? f2 : 1.0f;
        if (!z4 && !TextUtils.isEmpty(adLogoInfo.getAdurl())) {
            this.ag = ViewUtil.createAdImageView(new MutableContextWrapper(getContext()), adLogoInfo, f5);
        }
        if (TextUtils.isEmpty(adLogoInfo2.getAdurl())) {
            return;
        }
        this.ah = ViewUtil.createLogoImageView(new MutableContextWrapper(getContext()), adLogoInfo2, f5);
    }

    public void a(AdVideoView adVideoView, boolean z4) {
        ViewUtil.removeChildFromParent(this.f1774ad);
        AppCompatImageView createMuteButton = ViewUtil.createMuteButton(getContext(), z4, this.f1780q, this.C);
        this.f1774ad = createMuteButton;
        createMuteButton.setOnClickListener(new 33(this, adVideoView));
        ViewParent parent = adVideoView.getParent();
        if (parent instanceof FrameLayout) {
            ((FrameLayout) parent).addView(this.f1774ad);
        }
    }

    public void a(AdVideoView adVideoView) {
        ProgressBar progressBar = this.af;
        if (progressBar == null) {
            this.af = ViewUtil.createLoadingView(getContext(), this.C);
            ViewParent parent = adVideoView.getParent();
            if (parent instanceof FrameLayout) {
                ((FrameLayout) parent).addView(this.af);
                return;
            }
            return;
        }
        progressBar.setVisibility(0);
    }

    public void a(ComplianceInfo complianceInfo, float f2) {
        this.ae = ViewUtil.createComplianceView(getContext(), complianceInfo, f2, false);
    }

    public void a(int i3, int i4, View view) {
        ViewUtil.removeChildFromParent(this.f1773ab);
        ViewUtil.removeChildFromParent(this.V);
        if (this.f1773ab == null) {
            ImageView createImageCloseButton = ViewUtil.createImageCloseButton(getContext(), this.f1780q, this.C);
            this.f1773ab = createImageCloseButton;
            createImageCloseButton.setOnClickListener(new 2(this));
        }
        if (i4 > 0) {
            this.ao = i4;
        } else if (i3 > 0) {
            this.ao = i3;
        }
        if (this.ao > 0) {
            this.f1773ab.setVisibility(8);
            this.V = ViewUtil.createInterstitialCountDown(getContext(), this.f1780q, this.C);
            com.octopus.ad.a.a aVar = new com.octopus.ad.a.a(this.ao * 1000, 50L);
            this.ac = aVar;
            aVar.a((com.octopus.ad.a.b) new 3(this));
            this.ac.a();
        }
        ViewParent parent = k() ? view.getParent() : this;
        if (parent instanceof FrameLayout) {
            ImageView imageView = this.f1773ab;
            if (imageView != null) {
                ((FrameLayout) parent).addView(imageView);
            }
            View view2 = this.V;
            if (view2 != null) {
                ((FrameLayout) parent).addView(view2);
            }
        }
    }

    public void a(int i3) {
        AppCompatTextView appCompatTextView;
        com.octopus.ad.a.a aVar = this.ac;
        if (aVar != null) {
            aVar.d();
        }
        if (i3 <= 0) {
            this.ao = 5;
        } else {
            this.ao = i3;
        }
        this.V = ViewUtil.createCountDown(getContext(), this.f1780q, this.f1781r, this.C);
        com.octopus.ad.a.a aVar2 = new com.octopus.ad.a.a(this.ao * 1000, 50L);
        this.ac = aVar2;
        aVar2.a(new com.octopus.ad.a.b() {
            public void a(long j) {
                if (AdViewImpl.this.V == null) {
                    return;
                }
                AdViewImpl.this.getAdDispatcher().a(j);
                AdViewImpl.this.V.setText(String.format(Locale.US, "跳过 %d", Integer.valueOf((int) ((j / 1000) + 1))));
            }

            public void b() {
            }

            public void a() {
                if (AdViewImpl.this.V != null) {
                    AdViewImpl.this.V.setText("跳过 0");
                }
                a aVar3 = AdViewImpl.this.c;
                if (aVar3 != null) {
                    aVar3.a(true);
                    if (AdViewImpl.this.c.a()) {
                        if (AdViewImpl.this.c.c() == a.a.a || AdViewImpl.this.c.c() == a.a.b) {
                            AdViewImpl.this.U = true;
                            if (AdViewImpl.this.getAdDispatcher() != null) {
                                AdViewImpl.this.getAdDispatcher().a();
                            }
                        }
                    }
                }
            }
        });
        this.ac.a();
        ServerResponse serverResponse = this.b;
        if (serverResponse != null) {
            this.at = serverResponse.P();
            this.b.a(this.ac);
        }
        this.V.setOnClickListener(new 5(this));
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        ViewParent parent = k() ? adWebView.getParent() : this;
        if (!(parent instanceof FrameLayout) || (appCompatTextView = this.V) == null) {
            return;
        }
        ViewUtil.removeChildFromParent(appCompatTextView);
        ((FrameLayout) parent).addView(this.V);
    }

    public void a(int i3, int i4, int i5) {
        ViewUtil.removeChildFromParent(this.f1773ab);
        ViewUtil.removeChildFromParent(this.V);
        com.octopus.ad.a.a aVar = this.ac;
        if (aVar != null) {
            aVar.d();
        }
        if (this.f1773ab == null) {
            ImageView createImageCloseButton = ViewUtil.createImageCloseButton(getContext(), this.f1780q, 1.0f);
            this.f1773ab = createImageCloseButton;
            createImageCloseButton.setOnClickListener(new 6(this));
        }
        if (i3 != -1 && this.V == null) {
            this.f1781r = 30;
            this.V = ViewUtil.createCountDown(getContext(), this.f1780q, this.f1781r, this.C);
            this.ao = Math.min(i3, i5);
            if (i4 > 0) {
                this.f1773ab.setVisibility(8);
                int i6 = this.ao;
                if (i6 > i4) {
                    this.ap = i6 - i4;
                }
            }
            com.octopus.ad.a.a aVar2 = new com.octopus.ad.a.a(this.ao * 1000, 50L);
            this.ac = aVar2;
            aVar2.a((com.octopus.ad.a.b) new 7(this));
            this.ac.a();
            AdVideoView adVideoView = this.aC;
            if (adVideoView != null) {
                adVideoView.setCountDownTimer(this.ac);
            }
        }
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        ViewParent parent = k() ? adWebView.getParent() : this;
        if (parent instanceof FrameLayout) {
            ImageView imageView = this.f1773ab;
            if (imageView != null) {
                ((FrameLayout) parent).addView(imageView);
            }
            View view = this.V;
            if (view != null) {
                ((FrameLayout) parent).addView(view);
            }
        }
    }

    public void a(Context context) {
        try {
            AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.OctopusAlertDialogStyle);
            View inflate = LayoutInflater.from(context).inflate(R.layout.oct_dialog_close_confirm, (ViewGroup) null);
            builder.setView(inflate);
            TextView textView = (TextView) inflate.findViewById(R.id.tv_title);
            TextView textView2 = (TextView) inflate.findViewById(R.id.tv_quit);
            TextView textView3 = (TextView) inflate.findViewById(R.id.tv_wait);
            textView.setText(String.format(Locale.US, "观看满 %d 秒即可获得奖励\n确认离开吗?", Integer.valueOf(this.ao)));
            AlertDialog create = builder.create();
            textView2.setOnClickListener(new 8(this));
            textView3.setOnClickListener(new 9(this, create));
            create.show();
            AdVideoView adVideoView = this.aC;
            if (adVideoView != null) {
                adVideoView.onPause();
            } else {
                com.octopus.ad.a.a aVar = this.ac;
                if (aVar != null) {
                    aVar.b();
                }
            }
            create.setOnDismissListener(new 10(this));
        } catch (Exception e) {
            g.a("OctopusAd", "An Exception Caught", e);
        }
    }

    public void a(int i3, int i4, f fVar) {
        ViewUtil.removeChildFromParent(this.W);
        this.W = null;
        AdWebView adWebView = fVar.b;
        if (adWebView != null && adWebView.d) {
            ViewUtil.removeChildFromParent(adWebView);
            if (fVar.d() != null) {
                fVar.d().addView((View) fVar.b, 0);
            }
            if (fVar.c() != null) {
                fVar.c().finish();
            }
        }
        aT = null;
        aU = null;
        aV = null;
        a(i3, i4);
        this.g = true;
        this.f1775f = false;
    }

    private void a(int i3, int i4) {
        this.e = true;
        if (getLayoutParams() != null) {
            if (getLayoutParams().width > 0) {
                getLayoutParams().width = i3;
            }
            if (getLayoutParams().height > 0) {
                getLayoutParams().height = i4;
            }
        }
        if (this.P && (getParent() instanceof View)) {
            View view = (View) getParent();
            if (view.getLayoutParams() != null) {
                if (view.getLayoutParams().width > 0) {
                    view.getLayoutParams().width = i3;
                }
                if (view.getLayoutParams().height > 0) {
                    view.getLayoutParams().height = i4;
                }
            }
        }
    }

    public void a(f fVar, boolean z4, AdWebView.b bVar) {
        AdWebView adWebView = fVar.b;
        if (adWebView == null) {
            return;
        }
        fVar.a((ViewGroup) adWebView.getParent());
        FrameLayout frameLayout = new FrameLayout(getContext());
        ViewUtil.removeChildFromParent(fVar.b);
        frameLayout.addView(fVar.b);
        if (this.W == null) {
            AppCompatTextView createCloseButton = ViewUtil.createCloseButton(getContext());
            this.W = createCloseButton;
            createCloseButton.setOnClickListener(new 11(this, fVar));
        }
        frameLayout.addView(this.W);
        aT = frameLayout;
        aU = fVar;
        aV = bVar;
        Class a = AdActivity.a();
        try {
            Intent intent = new Intent(getContext(), (Class<?>) a);
            intent.putExtra("ACTIVITY_TYPE", "MRAID");
            getContext().startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            HaoboLog.e(HaoboLog.baseLogTag, HaoboLog.getString(R.string.adactivity_missing, a.getName()));
            aT = null;
            aU = null;
            aV = null;
        }
    }

    public void a(int i3, int i4, boolean z4, final f fVar, AdWebView.b bVar) {
        a(i3, i4);
        AppCompatTextView createCloseButton = ViewUtil.createCloseButton(getContext());
        this.W = createCloseButton;
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) createCloseButton.getLayoutParams();
        AdWebView adWebView = fVar.b;
        if (adWebView != null && !adWebView.d && getChildAt(0) != null) {
            layoutParams.rightMargin = (getMeasuredWidth() - getChildAt(0).getMeasuredWidth()) / 2;
        }
        this.W.setLayoutParams(layoutParams);
        this.W.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fVar.a();
            }
        });
        AdWebView adWebView2 = fVar.b;
        if (adWebView2 != null && adWebView2.d) {
            a(fVar, z4, bVar);
        } else {
            addView(this.W);
        }
        this.f1775f = true;
    }

    public void a(int i3, int i4, int i5, int i6, f.a aVar, boolean z4, final f fVar) {
        a(i3, i4);
        ViewUtil.removeChildFromParent(this.W);
        if (this.f1783y <= 0) {
            this.f1783y = (int) (getResources().getDisplayMetrics().density * 50.0f);
        }
        this.W = new 14(this, getContext(), fVar);
        int i7 = this.f1783y;
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(i7, i7, 17);
        int i8 = this.f1783y;
        int i10 = (i4 / 2) - (i8 / 2);
        int i11 = (i3 / 2) - (i8 / 2);
        int i12 = 27.a[aVar.ordinal()];
        if (i12 == 1) {
            layoutParams.topMargin = i10;
        } else if (i12 == 2) {
            layoutParams.rightMargin = i11;
            layoutParams.topMargin = i10;
        } else if (i12 == 3) {
            layoutParams.leftMargin = i11;
            layoutParams.topMargin = i10;
        } else if (i12 == 5) {
            layoutParams.bottomMargin = i10;
        } else if (i12 == 6) {
            layoutParams.rightMargin = i11;
            layoutParams.bottomMargin = i10;
        } else if (i12 == 7) {
            layoutParams.leftMargin = i11;
            layoutParams.bottomMargin = i10;
        }
        this.W.setLayoutParams(layoutParams);
        this.W.setBackgroundColor(0);
        this.W.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fVar.a();
            }
        });
        AdWebView adWebView = fVar.b;
        if (adWebView == null || adWebView.getParent() == null) {
            return;
        }
        ((ViewGroup) fVar.b.getParent()).addView(this.W);
    }

    public void a(HashMap hashMap) {
        if (!hashMap.isEmpty() && hashMap.containsKey("REWARD_ITEM")) {
            String str = (String) hashMap.get("REWARD_ITEM");
            try {
                if (str != null) {
                    JSONObject jSONObject = new JSONObject(str);
                    this.aJ = jSONObject.optString("callback_url");
                    this.aK = Pair.create(jSONObject.optString("name"), Integer.valueOf(jSONObject.optInt("amount")));
                    if (TextUtils.isEmpty(this.aJ) || getAdParameters() == null) {
                        return;
                    }
                    String extraData = getExtraData();
                    if (!TextUtils.isEmpty(extraData)) {
                        this.aJ += "&extra=" + extraData;
                    }
                    String userId = getUserId();
                    if (TextUtils.isEmpty(userId)) {
                        return;
                    }
                    this.aJ += "&userId=" + userId;
                    return;
                }
                this.aK = Pair.create("", 0);
            } catch (JSONException unused) {
                HaoboLog.e(HaoboLog.jsonLogTag, "Error parse reward item: " + str);
                this.aK = Pair.create("", 0);
            }
        }
    }

    public void a(String str, int i3) {
        RewardVideoAdListener rewardVideoAdListener;
        if (!this.T || (rewardVideoAdListener = this.H) == null) {
            return;
        }
        rewardVideoAdListener.onRewarded(new r(str, i3));
    }

    private void a(c.u uVar) {
        k kVar = this.aO;
        if (kVar == null || uVar == null) {
            return;
        }
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        kVar.a(uVar);
        this.aO.a(adWebView);
        View a = this.aO.a(adWebView, adWebView, 10.0f, uVar.e(), getMediaType());
        if (a != null) {
            if (uVar.b() == 1) {
                this.aB = 7;
            }
            this.aO.a(new 20(this));
            a.setOnTouchListener(new 21(this, new com.octopus.ad.model.d(1)));
            ViewParent parent = k() ? adWebView.getParent() : this;
            if ((parent instanceof FrameLayout) && uVar.g() == 1) {
                ((FrameLayout) parent).addView(a);
            }
        }
    }

    public void a(MotionEvent motionEvent, com.octopus.ad.model.d dVar) {
        try {
            if (motionEvent.getAction() == 0) {
                dVar.a(motionEvent.getRawX());
                dVar.b(motionEvent.getRawY());
                dVar.a(String.valueOf(System.currentTimeMillis()));
            } else if (motionEvent.getAction() == 1) {
                dVar.c(motionEvent.getRawX());
                dVar.d(motionEvent.getRawY());
                dVar.b(String.valueOf(System.currentTimeMillis()));
                AdWebView adWebView = this.aC;
                if (adWebView == null) {
                    adWebView = this.aD;
                }
                if (adWebView != null) {
                    dVar.a(adWebView.getWidth());
                    dVar.b(adWebView.getHeight());
                }
                a(dVar);
            }
        } catch (Exception e) {
            g.a("OctopusAd", "An Exception Caught", e);
        }
    }

    private void a(String str) {
        View a;
        j jVar = this.aP;
        if (jVar != null) {
            jVar.a();
            AdWebView adWebView = this.aC;
            if (adWebView == null) {
                adWebView = this.aD;
            }
            if (adWebView == null || (a = this.aP.a(ViewUtil.px2dip(getContext(), adWebView.getWidth()), ViewUtil.px2dip(getContext(), adWebView.getHeight()), str)) == null) {
                return;
            }
            a("up", 100, (j.a) new 24(this));
            ViewParent parent = k() ? adWebView.getParent() : this;
            if (parent instanceof FrameLayout) {
                ((FrameLayout) parent).addView(a);
            }
        }
    }

    private void a(final String str, int i3, final j.a aVar) {
        if (aVar != null) {
            this.aP.a(aVar);
        }
        final int dip2px = ViewUtil.dip2px(getContext(), i3);
        final com.octopus.ad.model.d dVar = new com.octopus.ad.model.d(3);
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        dVar.a(adWebView.getWidth());
        dVar.b(adWebView.getHeight());
        setScrollClick(new View.OnTouchListener() {
            public float a;
            public float b;
            public float c;
            public float d;
            public float e;

            public float f1785f;

            @Override
            @SuppressLint({"ClickableViewAccessibility"})
            public boolean onTouch(View view, MotionEvent motionEvent) {
                j.a aVar2;
                j.a aVar3;
                j.a aVar4;
                j.a aVar5;
                int action = motionEvent.getAction();
                if (action == 0) {
                    this.a = motionEvent.getX();
                    this.b = motionEvent.getY();
                    this.c = motionEvent.getX();
                    this.d = motionEvent.getY();
                    this.e = motionEvent.getRawX();
                    this.f1785f = motionEvent.getRawY();
                    dVar.a(motionEvent.getRawX());
                    dVar.b(motionEvent.getRawY());
                    dVar.a(String.valueOf(System.currentTimeMillis()));
                } else if (action == 1) {
                    dVar.c(motionEvent.getRawX());
                    dVar.d(motionEvent.getRawY());
                    dVar.b(String.valueOf(System.currentTimeMillis()));
                    float f2 = this.d;
                    float f5 = this.b;
                    if (f2 - f5 <= 0.0f || Math.abs(f2 - f5) <= dip2px) {
                        float f10 = this.d;
                        float f11 = this.b;
                        if (f10 - f11 >= 0.0f || Math.abs(f10 - f11) <= dip2px) {
                            float f12 = this.c;
                            float f13 = this.a;
                            if (f12 - f13 >= 0.0f || Math.abs(f12 - f13) <= dip2px) {
                                float f14 = this.c;
                                float f15 = this.a;
                                if (f14 - f15 < 0.0f && Math.abs(f14 - f15) > dip2px && "right".equalsIgnoreCase(str) && (aVar2 = aVar) != null) {
                                    aVar2.a(dVar);
                                }
                            } else if ("left".equalsIgnoreCase(str) && (aVar3 = aVar) != null) {
                                aVar3.a(dVar);
                            }
                        } else if ("up".equalsIgnoreCase(str) && (aVar4 = aVar) != null) {
                            aVar4.a(dVar);
                        }
                    } else if ("down".equalsIgnoreCase(str) && (aVar5 = aVar) != null) {
                        aVar5.a(dVar);
                    }
                } else if (action == 2) {
                    this.c = motionEvent.getX();
                    this.d = motionEvent.getY();
                }
                return true;
            }
        });
    }

    public void a(View.OnTouchListener onTouchListener) {
        AdWebView adWebView = this.aC;
        if (adWebView == null) {
            adWebView = this.aD;
        }
        if (adWebView == null) {
            return;
        }
        adWebView.setOnTouchListener(onTouchListener);
    }
}