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

import X.0CB;
import X.0CD;
import X.0CH;
import X.2GO;
import X.2HZ;
import X.6Is;
import X.7he;
import X.C0339K0c;
import X.C0762KGj;
import X.C0984KOx;
import X.C1567Kek;
import X.C1599KfG;
import X.C2261Kpw;
import X.C2903L0s;
import X.C3162LAr;
import X.C3166LAv;
import X.C3407LKc;
import X.Crj;
import X.Eed;
import X.FsD;
import X.ISm;
import X.LDV;
import X.LDW;
import X.LKA;
import X.LKB;
import X.LKC;
import X.LKD;
import X.LKG;
import X.LKY;
import X.M12;
import X.Rc9;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.ad.preload.AdLandPagePreloadServiceImpl;
import com.ss.android.ugc.aweme.ad.preload.IAdLandPagePreloadService;
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 java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;

public final class FeedAdLynxSurvey implements 6Is, 2HZ, 2GO {
    public static final LKY LJIILIIL = new LKY((byte) 0);
    public AwemeRawAd LIZ;
    public FsD LIZIZ;
    public long LIZJ = -1;
    public LDV LIZLLL;
    public LDW LJ;
    public C1567Kek LJFF;
    public View LJI;
    public C0984KOx LJII;
    public String LJIIIIZZ;
    public boolean LJIIIZ;
    public boolean LJIIJ;
    public final LKB LJIIJJI;
    public final FrameLayout LJIIL;
    public Aweme LJIILJJIL;
    public Integer LJIILL;
    public final Crj LJIILLIIL = 7he.LIZ(LKG.LIZ);
    public final View LJIIZILJ;
    public C1599KfG LJIJ;
    public final C2261Kpw LJIJI;
    public final C3162LAr LJIJJ;

    static {
        Covode.recordClassIndex(52775);
    }

    private final LKC LIZIZ() {
        return (LKC) this.LJIILLIIL.getValue();
    }

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(69, new Rc9(FeedAdLynxSurvey.class, "onHomeTabPressed", Eed.class, ThreadMode.MAIN, 0, false));
        hashMap.put(70, new Rc9(FeedAdLynxSurvey.class, "onSwipeUpEvent", C2903L0s.class, ThreadMode.MAIN, 0, false));
        return hashMap;
    }

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

    public final Bundle LIZ() {
        String str;
        Bundle bundle = new Bundle();
        Context context = this.LJIIL.getContext();
        LKC LIZIZ2 = LIZIZ();
        if (LIZIZ2 != null) {
            Aweme aweme = this.LJIILJJIL;
            n.LIZIZ(context, "");
            LIZIZ2.LIZ(bundle, aweme, context);
        }
        AwemeRawAd awemeRawAd = this.LIZ;
        if (awemeRawAd != null) {
            str = awemeRawAd.getNativeSiteCustomData();
        } else {
            str = null;
        }
        bundle.putString("bundle_native_site_custom_data", str);
        return bundle;
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public final void onSwipeUpEvent(C2903L0s l0s) {
        DataCenter dataCenter;
        M12.LIZ((Object) l0s);
        int i = 0;
        if (C3166LAv.LIZIZ.LIZ().LJFF) {
            int i2 = l0s.LIZ;
            C1567Kek kek = this.LJFF;
            if (kek != null) {
                i = kek.hashCode();
            }
            if (i2 != i) {
                return;
            }
        } else {
            int i3 = l0s.LIZ;
            C1599KfG kfG = this.LJIJ;
            if (kfG != null) {
                i = kfG.hashCode();
            }
            if (i3 != i) {
                return;
            }
        }
        String str = l0s.LIZIZ;
        if (str == null) {
            str = "";
        }
        this.LJIIIIZZ = str;
        LKB lkb = this.LJIIJJI;
        C3407LKc lKc = lkb.LIZJ;
        if (lKc != null && (dataCenter = lkb.LIZ) != null) {
            dataCenter.LIZ("action_ad_swipe_up_video", lKc);
        }
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public final void onHomeTabPressed(Eed eed) {
        Long l;
        int i;
        M12.LIZ((Object) eed);
        if (this.LJIIJJI.LIZIZ) {
            this.LJIIJJI.LIZIZ();
            C0762KGj LIZ2 = C0339K0c.LIZ("draw_ad", "othershow_over", this.LIZ);
            AwemeRawAd awemeRawAd = this.LIZ;
            if (awemeRawAd != null) {
                l = awemeRawAd.getAdId();
            } else {
                l = null;
            }
            LIZ2.LIZIZ("ad_id", l);
            LIZ2.LIZ("duration", Long.valueOf(System.currentTimeMillis() - this.LIZJ));
            FsD fsD = this.LIZIZ;
            if (fsD != null) {
                i = fsD.getId();
            } else {
                i = 0;
            }
            LIZ2.LIZ("five_star_survey_id", Integer.valueOf(i));
            LIZ2.LIZIZ();
        }
        EventBus.LIZ().LIZIZ(this);
    }

    public final void LIZ(Aweme aweme, int i) {
        AwemeRawAd awemeRawAd;
        this.LJIILJJIL = aweme;
        FsD fsD = null;
        if (aweme != null) {
            awemeRawAd = aweme.getAwemeRawAd();
        } else {
            awemeRawAd = null;
        }
        this.LIZ = awemeRawAd;
        this.LJIILL = Integer.valueOf(i);
        AwemeRawAd awemeRawAd2 = this.LIZ;
        if (awemeRawAd2 != null) {
            fsD = awemeRawAd2.getAdQuestionnaire();
        }
        this.LIZIZ = fsD;
    }

    public FeedAdLynxSurvey(LKB lkb, FrameLayout frameLayout) {
        View inflate;
        LDV ldv;
        LDW ldw;
        0CD lifecycle;
        String str;
        String str2;
        M12.LIZ((Object) lkb, (Object) frameLayout);
        MethodCollector.i(15679);
        this.LJIIJJI = lkb;
        this.LJIIL = frameLayout;
        0CH r3 = null;
        if (C3166LAv.LIZIZ.LIZ().LJFF) {
            inflate = View.inflate(frameLayout.getContext(), 2131560374, (ViewGroup) null);
            n.LIZIZ(inflate, "");
        } else {
            inflate = View.inflate(frameLayout.getContext(), 2131560373, (ViewGroup) null);
            n.LIZIZ(inflate, "");
        }
        this.LJIIZILJ = inflate;
        this.LJIIIIZZ = "";
        LKD lkd = new LKD(this);
        this.LJIJI = lkd;
        LKA lka = new LKA(this);
        this.LJIJJ = lka;
        frameLayout.removeAllViews();
        frameLayout.addView(inflate);
        this.LJIJ = (C1599KfG) inflate.findViewById(2131363068);
        this.LJFF = (C1567Kek) inflate.findViewById(2131370501);
        LKC LIZIZ2 = LIZIZ();
        if (LIZIZ2 != null) {
            C1599KfG kfG = this.LJIJ;
            IAdLandPagePreloadService LJFF2 = AdLandPagePreloadServiceImpl.LJFF();
            if (LJFF2 != null) {
                str2 = LJFF2.LJI("lynx_feed");
            } else {
                str2 = null;
            }
            ldv = LIZIZ2.LIZ(kfG, str2, (C2261Kpw) lkd);
        } else {
            ldv = null;
        }
        this.LIZLLL = ldv;
        LKC LIZIZ3 = LIZIZ();
        if (LIZIZ3 != null) {
            C1567Kek kek = this.LJFF;
            IAdLandPagePreloadService LJFF3 = AdLandPagePreloadServiceImpl.LJFF();
            if (LJFF3 != null) {
                str = LJFF3.LJI("lynx_feed");
            } else {
                str = null;
            }
            ldw = LIZIZ3.LIZ(kek, str, (C3162LAr) lka);
        } else {
            ldw = null;
        }
        this.LJ = ldw;
        0CH context = frameLayout.getContext();
        0CH r32 = context instanceof 0CH ? context : r3;
        if (r32 == null || (lifecycle = r32.getLifecycle()) == null) {
            MethodCollector.o(15679);
            return;
        }
        lifecycle.LIZ(this);
        MethodCollector.o(15679);
    }
}
