package com.ss.android.ugc.aweme.commercialize.views.cards;

import X.0CB;
import X.0CH;
import X.0CM;
import X.0CN;
import X.33g;
import X.C3238LDp;
import X.C3376LIx;
import X.D2Y;
import X.LJ0;
import X.LNS;
import X.LQ8;
import android.content.Context;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.arch.widgets.base.DataCenter;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeRawAd;
import com.ss.android.ugc.aweme.feed.model.CardStruct;
import org.greenrobot.eventbus.EventBus;

public abstract class AbsHalfWebPageActionV2 implements 0CM<33g>, LNS, LNS {
    public static final /* synthetic */ boolean LJII = true;
    public Context LIZIZ;
    public Aweme LIZJ;
    public LJ0 LIZLLL;
    public DataCenter LJ = new DataCenter();
    public boolean LJFF = false;
    public boolean LJI = false;

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_CREATE) {
            onCreate();
        } else if (r3 == 0CB.ON_RESUME) {
            onResume();
        } else if (r3 == 0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    public void LJ() {
        LJIIIZ();
    }

    public final boolean LJIIIIZZ() {
        return this.LJI;
    }

    @0CN(LIZ = 0CB.ON_CREATE)
    public void onCreate() {
        LJIIIZ();
    }

    @0CN(LIZ = 0CB.ON_RESUME)
    public void onResume() {
        LJIIIZ();
    }

    public void LJI() {
        LJIIIZ();
        this.LJI = true;
    }

    public void LJII() {
        LJIIIZ();
        this.LJI = false;
    }

    static {
        Covode.recordClassIndex(59972);
    }

    public final void LJIIIZ() {
        getClass().getSimpleName();
        hashCode();
    }

    public final void LIZJ() {
        this.LJ.LIZ(this);
        if (EventBus.LIZ().LIZ(this)) {
            EventBus.LIZ().LIZIZ(this);
        }
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public void onDestroy() {
        LJIIIZ();
        this.LIZLLL.LIZIZ().getLifecycle().LIZIZ(this);
    }

    public void LIZIZ() {
        DataCenter dataCenter = this.LJ;
        if (dataCenter != null) {
            dataCenter.LIZ("ON_AD_HALF_WEB_PAGE_SHOW", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_SHOW_FAIL", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_SHOW_CANCEL", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_CLICK_COVER", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_HIDE", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_EXPAND", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_EXPAND_FAIL", this);
            this.LJ.LIZ("ON_AD_HALF_WEB_PAGE_COLLAPSE", this);
        }
    }

    public void LIZLLL() {
        String str;
        long j;
        boolean z;
        LJIIIZ();
        if (LQ8.LIZIZ.LIZ() != null) {
            z = LQ8.LIZIZ.LIZ().LJI(this.LIZJ);
            str = LQ8.LIZIZ.LIZ().LIZLLL(this.LIZJ);
            j = LQ8.LIZIZ.LIZ().LJ(this.LIZJ);
        } else {
            str = "";
            j = 0;
            z = false;
        }
        C3376LIx lIx = new C3376LIx();
        lIx.LIZ("othershow");
        lIx.LIZIZ("card");
        lIx.LIZ(this.LIZJ);
        lIx.LIZ(z);
        lIx.LJFF(str);
        lIx.LIZ(j);
        LIZ(lIx.LIZ());
        if (this.LJFF) {
            this.LIZLLL.LIZ(false);
        }
    }

    public void LJFF() {
        String str;
        long j;
        LJIIIZ();
        if (LQ8.LIZIZ.LIZ() != null) {
            str = LQ8.LIZIZ.LIZ().LIZLLL(this.LIZJ);
            j = LQ8.LIZIZ.LIZ().LJ(this.LIZJ);
        } else {
            str = "";
            j = 0;
        }
        C3376LIx lIx = new C3376LIx();
        lIx.LIZ("close");
        lIx.LIZIZ("card");
        lIx.LIZ(this.LIZJ);
        lIx.LJFF(str);
        lIx.LIZ(j);
        LIZ(lIx.LIZ());
    }

    public void LIZIZ(String str) {
        LJIIIZ();
    }

    public final void LIZ(DataCenter dataCenter) {
        this.LJ = dataCenter;
        LIZIZ();
    }

    public final void LIZ(C3238LDp lDp) {
        LJIIIZ();
        if (LQ8.LIZIZ.LIZ() != null) {
            LQ8.LIZIZ.LIZ().LIZ(this.LIZIZ, lDp);
        }
        LIZIZ(lDp);
    }

    public void LIZ(String str) {
        boolean z;
        String str2;
        long j;
        LJIIIZ();
        if (LQ8.LIZIZ.LIZ() != null) {
            z = LQ8.LIZIZ.LIZ().LJI(this.LIZJ);
            str2 = LQ8.LIZIZ.LIZ().LIZLLL(this.LIZJ);
            j = LQ8.LIZIZ.LIZ().LJ(this.LIZJ);
        } else {
            z = false;
            str2 = "";
            j = 0;
        }
        C3376LIx lIx = new C3376LIx();
        lIx.LIZ("othershow_fail");
        lIx.LIZIZ("card");
        lIx.LIZJ(str);
        lIx.LIZ(this.LIZJ);
        lIx.LIZ(z);
        lIx.LJFF(str2);
        lIx.LIZ(j);
        LIZ(lIx.LIZ());
    }

    private void LIZIZ(C3238LDp lDp) {
        String str;
        if (LQ8.LIZIZ.LIZ() != null && LQ8.LIZIZ.LIZ().LJII(lDp.LIZ)) {
            if (LJII || lDp.LIZ.getAwemeRawAd() != null) {
                AwemeRawAd awemeRawAd = lDp.LIZ.getAwemeRawAd();
                String str2 = lDp.LIZIZ;
                str2.hashCode();
                if (!str2.equals("othershow")) {
                    if (str2.equals("click") && LQ8.LIZIZ.LIZ() != null) {
                        LQ8.LIZIZ.LIZ().LIZ("click", awemeRawAd);
                    }
                } else if (awemeRawAd.getCardInfos() != null) {
                    String str3 = lDp.LIZJ;
                    boolean equals = TextUtils.equals(str3, "card");
                    if (TextUtils.equals(str3, "coupon")) {
                        str = "4";
                    } else {
                        str = "3";
                    }
                    if (awemeRawAd.getCardInfos().containsKey(str)) {
                        CardStruct cardStruct = awemeRawAd.getCardInfos().get(str);
                        if (LQ8.LIZIZ.LIZ() != null) {
                            LQ8.LIZIZ.LIZ().LIZ("othershow", cardStruct.getTrackUrlList(), this.LIZJ);
                        }
                    }
                }
            } else {
                throw new AssertionError();
            }
        }
    }

    /* renamed from: LIZ */
    public void onChanged(33g r3) {
        if (r3 != null) {
            String str = r3.LIZ;
            str.hashCode();
            switch (str.hashCode()) {
                case -1528248849:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_EXPAND")) {
                        LJI();
                        return;
                    }
                    return;
                case -1501644853:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_CLICK_COVER")) {
                        LJ();
                        return;
                    }
                    return;
                case -1393672249:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_SHOW_CANCEL")) {
                        r3.LIZ();
                        LJIIIZ();
                        return;
                    }
                    return;
                case -201580690:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_EXPAND_FAIL")) {
                        LIZIZ((String) r3.LIZ());
                        return;
                    }
                    return;
                case 995285931:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_SHOW_FAIL")) {
                        LIZ((String) r3.LIZ());
                        return;
                    }
                    return;
                case 1538688450:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_COLLAPSE")) {
                        LJII();
                        return;
                    }
                    return;
                case 2116917719:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_HIDE")) {
                        D2Y d2y = (D2Y) r3.LIZ();
                        if (d2y == null || d2y.LIZIZ) {
                            LJFF();
                            return;
                        }
                        return;
                    }
                    return;
                case 2117244818:
                    if (str.equals("ON_AD_HALF_WEB_PAGE_SHOW")) {
                        LIZLLL();
                        return;
                    }
                    return;
                default:
                    return;
            }
        }
    }

    public AbsHalfWebPageActionV2(Context context, Aweme aweme, LJ0 lj0) {
        this.LIZIZ = context;
        this.LIZJ = aweme;
        this.LIZLLL = lj0;
        lj0.LIZIZ().getLifecycle().LIZ(this);
    }
}
