package com.ss.android.ugc.aweme.ad.feed.lynx;

import X.0CB;
import X.0CH;
import X.6Is;
import X.C0984KOx;
import X.C1567Kek;
import X.C1599KfG;
import X.C3401LJw;
import X.C3437LLg;
import X.LDV;
import X.LDW;
import X.LJH;
import X.LJX;
import X.LKC;
import X.M12;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.google.gson.m;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeRawAd;
import kotlin.h.b.n;

public abstract class AbstractFeedLynxView implements LJX, 6Is {
    public Aweme LIZ;
    public AwemeRawAd LIZIZ;
    public boolean LIZJ;
    public C3401LJw LIZLLL;
    public LKC LJ;
    public boolean LJFF;
    public View LJI;
    public C0984KOx LJII;
    public View LJIIIIZZ;
    public C1599KfG LJIIIZ;
    public C1567Kek LJIIJ;
    public final ViewGroup LJIIJJI;
    public final C3437LLg LJIIL;
    public final String LJIILIIL;

    static {
        Covode.recordClassIndex(52672);
    }

    public abstract String LIZ();

    public void LIZ(C3401LJw lJw) {
        M12.LIZ((Object) lJw);
    }

    public C3401LJw LIZIZ(String str) {
        return null;
    }

    public void LIZIZ(C3401LJw lJw) {
        M12.LIZ((Object) lJw);
    }

    public void LIZIZ(Aweme aweme) {
        M12.LIZ((Object) aweme);
    }

    public void LIZJ(String str) {
    }

    public abstract LDV LIZLLL();

    public abstract LDW LJ();

    public abstract int LJFF();

    public abstract boolean LJI();

    public boolean LJII() {
        return false;
    }

    public void LJIIJJI() {
    }

    public void onStateChanged(0CH r1, 0CB r2) {
    }

    public final C1599KfG LIZIZ() {
        C1599KfG kfG = this.LJIIIZ;
        if (kfG == null) {
            n.LIZ("");
        }
        return kfG;
    }

    public final C1567Kek LIZJ() {
        C1567Kek kek = this.LJIIJ;
        if (kek == null) {
            n.LIZ("");
        }
        return kek;
    }

    private final C1599KfG LJIILIIL() {
        Context context = this.LJIIJJI.getContext();
        n.LIZIZ(context, "");
        return new C1599KfG(context, (AttributeSet) null, 6, (byte) 0);
    }

    public m LJIIIZ() {
        LJH ljh = LJH.LIZ;
        Aweme aweme = this.LIZ;
        Context context = this.LJIIJJI.getContext();
        n.LIZIZ(context, "");
        return ljh.LIZ(aweme, context);
    }

    public Bundle LJIIJ() {
        LJH ljh = LJH.LIZ;
        Aweme aweme = this.LIZ;
        Context context = this.LJIIJJI.getContext();
        n.LIZIZ(context, "");
        return ljh.LIZIZ(aweme, context);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:3:0x0018, code lost:
        if (r2 != null) goto L_0x001a;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final X.C1567Kek LJIIL() {
        /*
            r5 = this;
            com.ss.android.ugc.aweme.spark.IAdSparkUtils r4 = com.ss.android.ugc.aweme.spark.AdSparkUtils.LIZIZ()
            java.lang.String r3 = ""
            if (r4 == 0) goto L_0x002e
            android.view.ViewGroup r0 = r5.LJIIJJI
            android.content.Context r2 = r0.getContext()
            kotlin.h.b.n.LIZIZ(r2, r3)
            r1 = 14
            r0 = 0
            com.ss.android.ugc.aweme.spark.AdSparkContext r2 = X.C1999Kli.LIZ(r4, r2, r0, r0, r1)
            if (r2 == 0) goto L_0x002e
        L_0x001a:
            X.Kh9 r1 = X.C1715Kh8.LJIIJJI
            android.view.ViewGroup r0 = r5.LJIIJJI
            android.content.Context r0 = r0.getContext()
            kotlin.h.b.n.LIZIZ(r0, r3)
            X.Kh8 r0 = r1.LIZ((android.content.Context) r0, (com.bytedance.hybrid.spark.SparkContext) r2)
            X.Kek r0 = r0.LIZIZ()
            return r0
        L_0x002e:
            com.bytedance.hybrid.spark.SparkContext r2 = new com.bytedance.hybrid.spark.SparkContext
            r2.<init>()
            goto L_0x001a
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ad.feed.lynx.AbstractFeedLynxView.LJIIL():X.Kek");
    }

    public final void LJIIIIZZ() {
        this.LJFF = false;
        String LIZ2 = LIZ();
        if (LIZ2 != null) {
            Uri.Builder buildUpon = Uri.parse(LIZ2).buildUpon();
            buildUpon.appendQueryParameter("initialData", LJIIIZ().toString());
            if (LJI()) {
                LDW LJ2 = LJ();
                if (LJ2 != null) {
                    String builder = buildUpon.toString();
                    n.LIZIZ(builder, "");
                    LJ2.LIZ(builder, LJIIJ());
                    return;
                }
                return;
            }
            LDV LIZLLL2 = LIZLLL();
            if (LIZLLL2 != null) {
                String builder2 = buildUpon.toString();
                n.LIZIZ(builder2, "");
                LIZLLL2.LIZ(builder2, LJIIJ());
            }
        }
    }

    public void LIZ(Aweme aweme) {
        AwemeRawAd awemeRawAd;
        this.LIZ = aweme;
        if (aweme != null) {
            awemeRawAd = aweme.getAwemeRawAd();
        } else {
            awemeRawAd = null;
        }
        this.LIZIZ = awemeRawAd;
        if (LJII()) {
            C3401LJw lJw = this.LIZLLL;
            if (lJw != null) {
                lJw.LIZLLL();
            }
            if (!this.LIZJ && aweme != null) {
                LIZIZ(aweme);
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:53:0x00d7, code lost:
        if (r0 == null) goto L_0x0080;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:55:0x00e3, code lost:
        if (r0 == null) goto L_0x0073;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public AbstractFeedLynxView(android.view.ViewGroup r8, X.C3437LLg r9, java.lang.String r10) {
        /*
            r7 = this;
            X.M12.LIZ((java.lang.Object) r8, (java.lang.Object) r9)
            r7.<init>()
            r7.LJIIJJI = r8
            r7.LJIIL = r9
            r7.LJIILIIL = r10
            com.ss.android.ugc.aweme.commercialize_ad_api.service.ICommercializeAdService r1 = com.ss.android.ugc.aweme.commercialize_x.service.CommercializeAdServiceImpl.LIZ()
            r0 = 17
            X.BS4 r1 = r1.LIZ(r0)
            boolean r0 = r1 instanceof X.LKC
            r2 = 0
            if (r0 != 0) goto L_0x001c
            r1 = r2
        L_0x001c:
            X.LKC r1 = (X.LKC) r1
            r7.LJ = r1
            boolean r0 = r7.LJII()
            if (r0 == 0) goto L_0x0057
            X.LJw r5 = r7.LIZIZ((java.lang.String) r10)
            if (r5 == 0) goto L_0x0057
            android.view.View r6 = r5.LIZJ
            if (r6 == 0) goto L_0x0057
            boolean r0 = r7.LJI()
            r4 = 1
            r3 = 3
            if (r0 == 0) goto L_0x00fc
            X.Kek r1 = r5.LJ
            if (r1 == 0) goto L_0x0057
            int r0 = r5.LIZIZ
            if (r0 != r3) goto L_0x0057
            r7.LIZLLL = r5
            r7.LJI = r6
            r7.LIZJ = r4
            boolean r0 = r5.LJII
            r7.LJFF = r0
            X.KOx r0 = r5.LJI
            r7.LJII = r0
            android.view.View r0 = r5.LJFF
            r7.LJIIIIZZ = r0
            r7.LJIIJ = r1
            r7.LIZIZ((X.C3401LJw) r5)
        L_0x0057:
            boolean r0 = r7.LIZJ
            java.lang.String r3 = ""
            if (r0 != 0) goto L_0x00e6
            android.content.Context r1 = r8.getContext()
            int r0 = r7.LJFF()
            android.view.View r1 = android.view.View.inflate(r1, r0, r2)
            kotlin.h.b.n.LIZIZ(r1, r3)
            r7.LJI = r1
            if (r1 != 0) goto L_0x00da
            kotlin.h.b.n.LIZ(r3)
        L_0x0073:
            X.KfG r0 = r7.LJIILIIL()
        L_0x0077:
            r7.LJIIIZ = r0
            android.view.View r1 = r7.LJI
            if (r1 != 0) goto L_0x00ce
            kotlin.h.b.n.LIZ(r3)
        L_0x0080:
            X.Kek r0 = r7.LJIIL()
        L_0x0084:
            r7.LJIIJ = r0
        L_0x0086:
            r8.removeAllViews()
            boolean r0 = r7.LIZJ
            if (r0 == 0) goto L_0x00ab
            android.view.View r0 = r7.LJI
            if (r0 != 0) goto L_0x0094
            kotlin.h.b.n.LIZ(r3)
        L_0x0094:
            android.view.ViewParent r1 = r0.getParent()
            boolean r0 = r1 instanceof android.view.ViewGroup
            if (r0 != 0) goto L_0x009d
            r1 = r2
        L_0x009d:
            android.view.ViewGroup r1 = (android.view.ViewGroup) r1
            if (r1 == 0) goto L_0x00ab
            android.view.View r0 = r7.LJI
            if (r0 != 0) goto L_0x00a8
            kotlin.h.b.n.LIZ(r3)
        L_0x00a8:
            r1.removeView(r0)
        L_0x00ab:
            android.view.View r0 = r7.LJI
            if (r0 != 0) goto L_0x00b2
            kotlin.h.b.n.LIZ(r3)
        L_0x00b2:
            r8.addView(r0)
            android.content.Context r1 = r8.getContext()
            boolean r0 = r1 instanceof X.0CH
            if (r0 != 0) goto L_0x00cc
        L_0x00bd:
            X.0CH r2 = (X.0CH) r2
            if (r2 == 0) goto L_0x00cb
            X.0CD r1 = r2.getLifecycle()
            if (r1 == 0) goto L_0x00cb
            r0 = r7
            r1.LIZ(r0)
        L_0x00cb:
            return
        L_0x00cc:
            r2 = r1
            goto L_0x00bd
        L_0x00ce:
            r0 = 2131370500(0x7f0a2204, float:1.8361008E38)
            android.view.View r0 = r1.findViewById(r0)
            X.Kek r0 = (X.C1567Kek) r0
            if (r0 != 0) goto L_0x0084
            goto L_0x0080
        L_0x00da:
            r0 = 2131363067(0x7f0a04fb, float:1.8345932E38)
            android.view.View r0 = r1.findViewById(r0)
            X.KfG r0 = (X.C1599KfG) r0
            if (r0 != 0) goto L_0x0077
            goto L_0x0073
        L_0x00e6:
            r1 = r7
            X.KfG r0 = r1.LJIIIZ
            if (r0 != 0) goto L_0x00f1
            X.KfG r0 = r7.LJIILIIL()
            r7.LJIIIZ = r0
        L_0x00f1:
            X.Kek r0 = r1.LJIIJ
            if (r0 != 0) goto L_0x0086
            X.Kek r0 = r7.LJIIL()
            r7.LJIIJ = r0
            goto L_0x0086
        L_0x00fc:
            X.KfG r1 = r5.LIZLLL
            if (r1 == 0) goto L_0x0057
            int r0 = r5.LIZIZ
            if (r0 != r3) goto L_0x0057
            r7.LIZLLL = r5
            r7.LJI = r6
            r7.LIZJ = r4
            boolean r0 = r5.LJII
            r7.LJFF = r0
            X.KOx r0 = r5.LJI
            r7.LJII = r0
            android.view.View r0 = r5.LJFF
            r7.LJIIIIZZ = r0
            r7.LJIIIZ = r1
            r7.LIZ((X.C3401LJw) r5)
            goto L_0x0057
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ad.feed.lynx.AbstractFeedLynxView.<init>(android.view.ViewGroup, X.LLg, java.lang.String):void");
    }
}
