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

import X.0AA;
import X.0AP;
import X.0CB;
import X.0CC;
import X.0CD;
import X.0CH;
import X.0CN;
import X.0HH;
import X.1hK;
import X.2GO;
import X.2HZ;
import X.2Jj;
import X.2Jk;
import X.2te;
import X.2th;
import X.3GY;
import X.4Zv;
import X.6Is;
import X.7XM;
import X.7he;
import X.C0339K0c;
import X.C0762KGj;
import X.C1567Kek;
import X.C1569Kem;
import X.C3011L4w;
import X.C3162LAr;
import X.C3409LKe;
import X.C3410LKf;
import X.C3415LKk;
import X.C3416LKl;
import X.C3417LKm;
import X.C3418LKn;
import X.C3419LKo;
import X.C3421LKq;
import X.C3424LKt;
import X.C3427LKw;
import X.C3428LKx;
import X.C3430LKz;
import X.C4116Lel;
import X.Crj;
import X.D4J;
import X.D5O;
import X.FLK;
import X.FMA;
import X.FMD;
import X.ISm;
import X.L58;
import X.LDW;
import X.LKC;
import X.LL0;
import X.LL4;
import X.LL5;
import X.LL6;
import X.LL8;
import X.M12;
import X.Rc9;
import X.SsI;
import android.app.Dialog;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import android.util.Pair;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import androidx.fragment.app.DialogFragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.hox.Hox;
import com.ss.android.ugc.aweme.ad.preload.AdLandPagePreloadServiceImpl;
import com.ss.android.ugc.aweme.ad.preload.IAdLandPagePreloadService;
import com.ss.android.ugc.aweme.crossplatform.activity.CrossPlatformFragment;
import com.ss.android.ugc.aweme.crossplatform.activity.MixActivityContainer;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeRawAd;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kotlin.h.b.n;
import org.greenrobot.eventbus.ThreadMode;

public final class ShakeEgg implements SensorEventListener, FMA, 6Is, 2HZ, 2GO {
    public static final LL6 LJIIJJI = new LL6((byte) 0);
    public ShakeEggVM LIZ;
    public final List<String> LIZIZ = new ArrayList();
    public boolean LIZJ;
    public boolean LIZLLL;
    public boolean LJ;
    public boolean LJFF;
    public boolean LJI;
    public int LJII;
    public CrossPlatformFragment LJIIIIZZ;
    public boolean LJIIIZ;
    public final 1hK LJIIJ;
    public Hox LJIIL;
    public final Crj LJIILIIL = 7he.LIZ(new C3424LKt(this));
    public final Crj LJIILJJIL = 7he.LIZ(new C3427LKw(this));
    public final Crj LJIILL = 7he.LIZ(new C3428LKx(this));
    public C1567Kek LJIILLIIL;
    public final Crj LJIIZILJ = 7he.LIZ(new 2Jj(this));
    public final Crj LJIJ = 7he.LIZ(new 2Jk(this));
    public final Crj LJIJI = 7he.LIZ(new LL0(this));
    public final Crj LJIJJ = 7he.LIZ(new C3430LKz(this));
    public float LJIJJLI;
    public int LJIL;
    public boolean LJJ;
    public final C3162LAr LJJI = new C3410LKf(this);

    static {
        Covode.recordClassIndex(52718);
    }

    private final FrameLayout LJIIJ() {
        return (FrameLayout) this.LJIILJJIL.getValue();
    }

    private final SensorManager LJIIJJI() {
        return (SensorManager) this.LJIJ.getValue();
    }

    private final LL8 LJIIL() {
        return (LL8) this.LJIJI.getValue();
    }

    private final LL8 LJIILIIL() {
        return (LL8) this.LJIJJ.getValue();
    }

    public final FrameLayout LIZIZ() {
        return (FrameLayout) this.LJIILIIL.getValue();
    }

    public final D5O LIZJ() {
        return (D5O) this.LJIILL.getValue();
    }

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(481, new Rc9(ShakeEgg.class, "shakeJsb", 7XM.class, ThreadMode.MAIN, 0, false));
        return hashMap;
    }

    public final void onAccuracyChanged(Sensor sensor, int i) {
    }

    public final void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_CREATE) {
            onActivityCreate();
        } else if (r3 == 0CB.ON_DESTROY) {
            onActivityDestroy();
        }
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public final void onActivityDestroy() {
        SsI.LIZIZ(this);
    }

    private final void LJIILJJIL() {
        SensorManager LJIIJJI2 = LJIIJJI();
        if (LJIIJJI2 != null) {
            LJIIJJI2.unregisterListener(this);
        }
        this.LJJ = false;
    }

    public final void LJIIIIZZ() {
        LJII();
        LJFF();
        LJI();
    }

    public final void LJI() {
        LIZJ().setVisibility(8);
        LL8 LJIIL2 = LJIIL();
        if (LJIIL2 != null) {
            LJIIL2.LIZ(false);
        }
        LIZIZ(false);
    }

    private final boolean LJIILL() {
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        if (!shakeEggVM.LIZJ && !(!this.LIZIZ.isEmpty()) && !LJIILLIIL()) {
            return false;
        }
        return true;
    }

    private final boolean LJIILLIIL() {
        0AA supportFragmentManager = this.LJIIJ.getSupportFragmentManager();
        n.LIZIZ(supportFragmentManager, "");
        List<DialogFragment> LJFF2 = supportFragmentManager.LJFF();
        n.LIZIZ(LJFF2, "");
        if (LJFF2.isEmpty()) {
            return false;
        }
        for (DialogFragment dialogFragment : LJFF2) {
            if (dialogFragment instanceof DialogFragment) {
                Dialog dialog = dialogFragment.getDialog();
                n.LIZIZ(dialog, "");
                if (dialog.isShowing()) {
                    return true;
                }
            }
        }
        return false;
    }

    public final void LIZLLL() {
        LJIIIIZZ();
        LJIILJJIL();
        this.LIZIZ.clear();
        C3421LKq lKq = C3421LKq.LIZ;
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        if (!lKq.LIZIZ((Aweme) shakeEggVM.LIZ.getValue())) {
            LIZ(true);
        }
        ShakeEggVM shakeEggVM2 = this.LIZ;
        if (shakeEggVM2 == null) {
            n.LIZ("");
        }
        shakeEggVM2.LIZIZ = false;
    }

    public final void LJFF() {
        AwemeRawAd awemeRawAd;
        if (LIZJ().getVisibility() != 8) {
            LIZJ().setVisibility(8);
            ShakeEggVM shakeEggVM = this.LIZ;
            if (shakeEggVM == null) {
                n.LIZ("");
            }
            Aweme aweme = (Aweme) shakeEggVM.LIZ.getValue();
            if (aweme != null) {
                awemeRawAd = aweme.getAwemeRawAd();
            } else {
                awemeRawAd = null;
            }
            C0762KGj LIZ2 = C0339K0c.LIZ("draw_ad", "interaction_card_close", awemeRawAd);
            LIZ2.LIZIZ("refer", "shake_guidance");
            LIZ2.LIZIZ();
        }
    }

    public final void LJIIIZ() {
        CrossPlatformFragment crossPlatformFragment = new CrossPlatformFragment();
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        crossPlatformFragment.setArguments(shakeEggVM.LIZLLL);
        crossPlatformFragment.LIZ(new LL4(this));
        FrameLayout LJIIJ2 = LJIIJ();
        0AP LIZ2 = this.LJIIJ.getSupportFragmentManager().LIZ();
        LIZ2.LIZIZ(LJIIJ2.getId(), crossPlatformFragment);
        LIZ2.LIZJ();
        if (this.LIZ == null) {
            n.LIZ("");
        }
        this.LJIIIIZZ = crossPlatformFragment;
    }

    @0CN(LIZ = 0CB.ON_CREATE)
    public final void onActivityCreate() {
        SsI.LIZ(this);
        this.LIZ = ShakeEggVM.LJIIZILJ.LIZ(this.LJIIJ);
        this.LJIIL = Hox.LJ.LIZ(this.LJIIJ);
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        shakeEggVM.LIZ.observe(this.LJIIJ, new C3415LKk(this));
        ShakeEggVM shakeEggVM2 = this.LIZ;
        if (shakeEggVM2 == null) {
            n.LIZ("");
        }
        shakeEggVM2.LJIIIZ.observe(this.LJIIJ, new C3418LKn(this));
    }

    public final LDW LIZ() {
        LKC LIZ2 = C3409LKe.LIZ();
        String str = null;
        if (LIZ2 == null) {
            return null;
        }
        C1567Kek kek = this.LJIILLIIL;
        if (kek == null) {
            kek = (C1567Kek) 0HH.LIZ(this.LJIIJ.getLayoutInflater(), 2131560384, LIZJ(), true).findViewById(2131364828);
            n.LIZIZ(kek, "");
        }
        this.LJIILLIIL = kek;
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        shakeEggVM.LJFF = true;
        IAdLandPagePreloadService LJFF2 = AdLandPagePreloadServiceImpl.LJFF();
        if (LJFF2 != null) {
            str = LJFF2.LJI("lynx_feed");
        }
        return LIZ2.LIZ(kek, str, this.LJJI);
    }

    public final void LJII() {
        String aid;
        String aid2;
        MixActivityContainer mixActivityContainer;
        if (LJIIJ().getVisibility() != 8) {
            LJIIJ().setVisibility(8);
            CrossPlatformFragment crossPlatformFragment = this.LJIIIIZZ;
            if (!(crossPlatformFragment == null || (mixActivityContainer = crossPlatformFragment.LIZ) == null)) {
                mixActivityContainer.LJIJJLI();
            }
            ShakeEggVM shakeEggVM = this.LIZ;
            if (shakeEggVM == null) {
                n.LIZ("");
            }
            shakeEggVM.LIZJ = false;
            ShakeEggVM shakeEggVM2 = this.LIZ;
            if (shakeEggVM2 == null) {
                n.LIZ("");
            }
            Aweme aweme = (Aweme) shakeEggVM2.LIZ.getValue();
            if (!(aweme == null || (aid2 = aweme.getAid()) == null)) {
                shakeEggVM2.LJIILLIIL.setValue(aid2);
            }
            LL8 LJIILIIL2 = LJIILIIL();
            if (LJIILIIL2 != null) {
                LJIILIIL2.LIZ(false);
            }
            ShakeEggVM shakeEggVM3 = this.LIZ;
            if (shakeEggVM3 == null) {
                n.LIZ("");
            }
            Aweme aweme2 = (Aweme) shakeEggVM3.LIZ.getValue();
            if (aweme2 != null && (aid = aweme2.getAid()) != null) {
                shakeEggVM3.LJIILJJIL.setValue(aid);
            }
        }
    }

    public final void LJ() {
        String str;
        AwemeRawAd awemeRawAd;
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        Aweme aweme = (Aweme) shakeEggVM.LIZ.getValue();
        if (aweme != null) {
            n.LIZIZ(aweme, "");
            if (this.LJI) {
                LIZ("show");
                this.LJI = false;
            }
            Sensor sensor = null;
            if (!this.LIZJ) {
                str = "data_load_fail";
            } else if (!this.LIZLLL) {
                str = "load_timeout";
            } else if (LJIIJJI() == null) {
                str = "shake_fail";
            } else {
                str = null;
            }
            if (str != null) {
                C0762KGj LIZ2 = C0339K0c.LIZ("draw_ad", "othershow_fail", aweme.getAwemeRawAd());
                LIZ2.LIZIZ("refer", "shake_guidance");
                LIZ2.LIZ("fail_reason", str);
                LIZ2.LIZIZ();
                return;
            }
            C3421LKq lKq = C3421LKq.LIZ;
            ShakeEggVM shakeEggVM2 = this.LIZ;
            if (shakeEggVM2 == null) {
                n.LIZ("");
            }
            if (lKq.LIZIZ((Aweme) shakeEggVM2.LIZ.getValue()) && LIZJ(false) && !LJIILL() && LIZJ().getVisibility() != 0) {
                LIZJ().setVisibility(0);
                if (this.LJFF) {
                    ShakeEggVM shakeEggVM3 = this.LIZ;
                    if (shakeEggVM3 == null) {
                        n.LIZ("");
                    }
                    Aweme aweme2 = (Aweme) shakeEggVM3.LIZ.getValue();
                    if (aweme2 != null) {
                        awemeRawAd = aweme2.getAwemeRawAd();
                    } else {
                        awemeRawAd = null;
                    }
                    C0762KGj LIZ3 = C0339K0c.LIZ("draw_ad", "othershow", awemeRawAd);
                    LIZ3.LIZIZ("refer", "shake_guidance");
                    LIZ3.LIZIZ();
                    this.LJFF = false;
                }
                LIZIZ(false);
                if (!this.LJJ) {
                    SensorManager LJIIJJI2 = LJIIJJI();
                    if (LJIIJJI2 != null) {
                        SensorManager LJIIJJI3 = LJIIJJI();
                        if (LJIIJJI3 != null) {
                            3GY.LIZ(100703);
                            Pair LIZ4 = 3GY.LIZ((Object) null, LJIIJJI3, new Object[]{1}, 100703, "android.hardware.Sensor", false, 1735442167, 2);
                            if (((Boolean) LIZ4.first).booleanValue()) {
                                sensor = (Sensor) LIZ4.second;
                            } else {
                                sensor = LJIIJJI3.getDefaultSensor(1);
                            }
                        }
                        LJIIJJI2.registerListener(this, sensor, 2);
                    }
                    this.LJJ = true;
                }
            }
        }
    }

    public static final /* synthetic */ ShakeEggVM LIZ(ShakeEgg shakeEgg) {
        ShakeEggVM shakeEggVM = shakeEgg.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        return shakeEggVM;
    }

    private final void LIZIZ(boolean z) {
        D5O LIZJ2 = LIZJ();
        if (z) {
            LIZJ2.setTouchToGone(false);
            LIZJ2.setClickable(true);
            LIZJ2.setEnabled(true);
            return;
        }
        LIZJ2.setTouchToGone(true);
        LIZJ2.setClickable(false);
        LIZJ2.setEnabled(false);
    }

    private final boolean LIZJ(boolean z) {
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        if (!shakeEggVM.LIZIZ) {
            return false;
        }
        Hox hox = this.LJIIL;
        if (hox == null) {
            n.LIZ("");
        }
        if (!hox.LIZJ("For You")) {
            return false;
        }
        if (z) {
            return true;
        }
        0CD lifecycle = this.LJIIJ.getLifecycle();
        n.LIZIZ(lifecycle, "");
        if (lifecycle.LIZ() != 0CC.RESUMED) {
            return false;
        }
        return true;
    }

    public final void LIZ(String str) {
        AwemeRawAd awemeRawAd;
        ShakeEggVM shakeEggVM = this.LIZ;
        if (shakeEggVM == null) {
            n.LIZ("");
        }
        Aweme aweme = (Aweme) shakeEggVM.LIZ.getValue();
        if (aweme != null) {
            awemeRawAd = aweme.getAwemeRawAd();
        } else {
            awemeRawAd = null;
        }
        C0762KGj LIZ2 = C0339K0c.LIZ("draw_ad", "shake_egg_timing", awemeRawAd);
        LIZ2.LIZ("timing", str);
        LIZ2.LIZIZ();
    }

    public ShakeEgg(1hK r3) {
        M12.LIZ((Object) r3);
        this.LJIIJ = r3;
        r3.getLifecycle().LIZ(this);
    }

    public final void LIZ(boolean z) {
        MethodCollector.i(17100);
        this.LIZJ = false;
        this.LIZLLL = false;
        this.LJ = false;
        if (z) {
            ShakeEggVM shakeEggVM = this.LIZ;
            if (shakeEggVM == null) {
                n.LIZ("");
            }
            shakeEggVM.LJFF = false;
            CrossPlatformFragment crossPlatformFragment = this.LJIIIIZZ;
            if (crossPlatformFragment != null) {
                0AP LIZ2 = this.LJIIJ.getSupportFragmentManager().LIZ();
                LIZ2.LIZ(crossPlatformFragment);
                LIZ2.LIZJ();
            }
            this.LJIIIIZZ = null;
            C1567Kek kek = this.LJIILLIIL;
            if (kek != null) {
                kek.LIZJ();
                ViewParent parent = kek.getParent();
                if (!(parent instanceof ViewGroup)) {
                    parent = null;
                }
                ViewGroup viewGroup = (ViewGroup) parent;
                if (viewGroup != null) {
                    viewGroup.removeView(kek);
                }
            }
            this.LJIILLIIL = null;
        }
        MethodCollector.o(17100);
    }

    public final void onSensorChanged(SensorEvent sensorEvent) {
        float f;
        float f2;
        float f3;
        float f4;
        C1569Kem kitView;
        float[] fArr;
        float[] fArr2;
        float[] fArr3;
        if (LIZJ(false) && !LJIILL()) {
            C3421LKq lKq = C3421LKq.LIZ;
            ShakeEggVM shakeEggVM = this.LIZ;
            if (shakeEggVM == null) {
                n.LIZ("");
            }
            if (lKq.LIZIZ((Aweme) shakeEggVM.LIZ.getValue())) {
                C3421LKq lKq2 = C3421LKq.LIZ;
                ShakeEggVM shakeEggVM2 = this.LIZ;
                if (shakeEggVM2 == null) {
                    n.LIZ("");
                }
                C3419LKo LIZ2 = lKq2.LIZ((Aweme) shakeEggVM2.LIZ.getValue());
                if (LIZ2 != null) {
                    if (LIZ2.getSpeed() != 0.0f) {
                        f = LIZ2.getSpeed();
                    } else {
                        f = 18.0f;
                    }
                    SensorEvent sensorEvent2 = sensorEvent;
                    if (sensorEvent2 == null || (fArr3 = sensorEvent2.values) == null) {
                        f2 = 0.0f;
                    } else {
                        f2 = fArr3[0];
                    }
                    if (sensorEvent2 == null || (fArr2 = sensorEvent2.values) == null) {
                        f3 = 0.0f;
                    } else {
                        f3 = fArr2[1];
                    }
                    if (sensorEvent2 == null || (fArr = sensorEvent2.values) == null) {
                        f4 = 0.0f;
                    } else {
                        f4 = fArr[2];
                    }
                    if (Math.sqrt(Math.pow((double) f2, 2.0d) + Math.pow((double) f3, 2.0d) + Math.pow((double) f4, 2.0d)) >= ((double) f) && this.LJIJJLI * f2 <= 0.0f) {
                        this.LJIL++;
                        this.LJIJJLI = f2;
                    }
                    if (this.LJIL >= 2) {
                        Vibrator vibrator = (Vibrator) this.LJIIZILJ.getValue();
                        AwemeRawAd awemeRawAd = null;
                        if (vibrator == null) {
                            ShakeEggVM shakeEggVM3 = this.LIZ;
                            if (shakeEggVM3 == null) {
                                n.LIZ("");
                            }
                            Aweme aweme = (Aweme) shakeEggVM3.LIZ.getValue();
                            if (aweme != null) {
                                awemeRawAd = aweme.getAwemeRawAd();
                            }
                            C0339K0c.LIZ("draw_ad", "vibrate_fail", awemeRawAd).LIZIZ();
                        } else if (!4Zv.LJFF(this.LJIIJ) && 4Zv.LIZ.getRingerMode() > 0) {
                            vibrator.vibrate(500);
                        } else {
                            ShakeEggVM shakeEggVM4 = this.LIZ;
                            if (shakeEggVM4 == null) {
                                n.LIZ("");
                            }
                            Aweme aweme2 = (Aweme) shakeEggVM4.LIZ.getValue();
                            if (aweme2 != null) {
                                awemeRawAd = aweme2.getAwemeRawAd();
                            }
                            C0339K0c.LIZ("draw_ad", "vibrate_fail", awemeRawAd).LIZIZ();
                        }
                        C1567Kek kek = this.LJIILLIIL;
                        if (!(kek == null || (kitView = kek.getKitView()) == null)) {
                            kitView.LIZ("shake_eggs_shake", (List<? extends Object>) C4116Lel.INSTANCE);
                        }
                        LIZ("shake");
                        this.LJIJJLI = 0.0f;
                        this.LJIL = 0;
                    }
                }
            }
        }
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public final void shakeJsb(7XM r10) {
        Object obj;
        CrossPlatformFragment crossPlatformFragment;
        MixActivityContainer mixActivityContainer;
        String aid;
        MixActivityContainer mixActivityContainer2;
        M12.LIZ((Object) r10);
        Object opt = r10.LIZ.opt("key");
        if (opt != null) {
            if (n.LIZ(opt, "shake_eggs_lynx_ready")) {
                LIZ("lynx_ready");
                this.LIZLLL = true;
            } else if (n.LIZ(opt, "shake_eggs_startPlay")) {
                long optLong = r10.LIZ.optLong("stayTime");
                LIZ("start_play");
                C3421LKq lKq = C3421LKq.LIZ;
                ShakeEggVM shakeEggVM = this.LIZ;
                if (shakeEggVM == null) {
                    n.LIZ("");
                }
                if (lKq.LIZIZ((Aweme) shakeEggVM.LIZ.getValue())) {
                    LJIILJJIL();
                    C3421LKq lKq2 = C3421LKq.LIZ;
                    ShakeEggVM shakeEggVM2 = this.LIZ;
                    if (shakeEggVM2 == null) {
                        n.LIZ("");
                    }
                    C3419LKo LIZ2 = lKq2.LIZ((Aweme) shakeEggVM2.LIZ.getValue());
                    if (LIZ2 != null) {
                        LIZ2.setShaken(true);
                    }
                    this.LJ = true;
                    if (LIZJ(true) && optLong != 0) {
                        D5O LIZJ2 = LIZJ();
                        LIZIZ(true);
                        LIZJ2.setVisibility(0);
                        LL8 LJIIL2 = LJIIL();
                        if (LJIIL2 != null) {
                            LJIIL2.LIZ(true);
                        }
                        new Handler(Looper.getMainLooper()).postDelayed(new LL5(this, optLong), optLong);
                    }
                }
            } else if (n.LIZ(opt, "shake_eggs_lynx_finish")) {
                LIZ("lynx_finish");
                LJI();
            } else if (n.LIZ(opt, "shake_eggs_openlandingpage") && LIZJ(true)) {
                LIZ("open_landingpage");
                try {
                    obj = r10.LIZ.optString("web_url");
                    2te.constructor-impl(obj);
                } catch (Throwable th) {
                    obj = 2th.LIZ(th);
                    2te.constructor-impl(obj);
                }
                AwemeRawAd awemeRawAd = null;
                if (2te.isFailure-impl(obj)) {
                    obj = null;
                }
                String str = (String) obj;
                if (str != null && (crossPlatformFragment = this.LJIIIIZZ) != null && (mixActivityContainer = crossPlatformFragment.LIZ) != null) {
                    mixActivityContainer.LIZIZ(str);
                    if (LJIIJ().getVisibility() != 0) {
                        ShakeEggVM shakeEggVM3 = this.LIZ;
                        if (shakeEggVM3 == null) {
                            n.LIZ("");
                        }
                        shakeEggVM3.LIZ();
                        LJIIJ().setVisibility(0);
                        CrossPlatformFragment crossPlatformFragment2 = this.LJIIIIZZ;
                        if (!(crossPlatformFragment2 == null || (mixActivityContainer2 = crossPlatformFragment2.LIZ) == null)) {
                            mixActivityContainer2.LJIJJ();
                        }
                        ShakeEggVM shakeEggVM4 = this.LIZ;
                        if (shakeEggVM4 == null) {
                            n.LIZ("");
                        }
                        shakeEggVM4.LIZJ = true;
                        ShakeEggVM shakeEggVM5 = this.LIZ;
                        if (shakeEggVM5 == null) {
                            n.LIZ("");
                        }
                        Aweme aweme = (Aweme) shakeEggVM5.LIZ.getValue();
                        if (!(aweme == null || (aid = aweme.getAid()) == null)) {
                            shakeEggVM5.LJIILL.setValue(aid);
                        }
                        LL8 LJIILIIL2 = LJIILIIL();
                        if (LJIILIIL2 != null) {
                            LJIILIIL2.LIZ(true);
                        }
                        ShakeEggVM shakeEggVM6 = this.LIZ;
                        if (shakeEggVM6 == null) {
                            n.LIZ("");
                        }
                        Aweme aweme2 = (Aweme) shakeEggVM6.LIZ.getValue();
                        if (aweme2 != null) {
                            awemeRawAd = aweme2.getAwemeRawAd();
                        }
                        C0339K0c.LIZ("draw_ad", "open_url_h5", awemeRawAd).LIZIZ();
                    }
                }
            }
        }
    }

    public final void LIZ(Aweme aweme, boolean z) {
        List<String> geckoChannel;
        String str;
        LJFF();
        LIZ(false);
        C3419LKo LIZ2 = C3421LKq.LIZ.LIZ(aweme);
        if (LIZ2 != null && (geckoChannel = LIZ2.getGeckoChannel()) != null) {
            for (String next : geckoChannel) {
                L58 l58 = D4J.LIZ;
                n.LIZIZ(l58, "");
                C3011L4w LIZJ2 = l58.LIZJ();
                if (LIZJ2 != null) {
                    IAdLandPagePreloadService LJFF2 = AdLandPagePreloadServiceImpl.LJFF();
                    if (LJFF2 != null) {
                        str = LJFF2.LJI("lynx_feed");
                    } else {
                        str = null;
                    }
                    if (!LIZJ2.LIZ(str, next)) {
                        return;
                    }
                }
            }
            C3416LKl lKl = new C3416LKl(this, aweme, z);
            if (FMD.LIZ().LIZIZ == 0 || !FLK.LIZJ(aweme)) {
                lKl.LIZ();
            } else {
                new Handler(Looper.getMainLooper()).postDelayed(new C3417LKm(lKl), FMD.LIZ().LIZIZ);
            }
        }
    }
}
