package com.ss.android.ugc.aweme.detail.panel;

import X.0HH;
import X.7he;
import X.AnonymousClass2GO;
import X.C02062Ma;
import X.C08622hC;
import X.C34723iC;
import X.C34743iE;
import X.C34763iG;
import X.C34773iH;
import X.Crj;
import X.HeD;
import X.ISm;
import X.M12;
import X.MNS;
import X.Qeg;
import X.Rc9;
import X.T3s;
import X.TnV;
import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.duetmode.impl.DuetDiscoverServiceImpl;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import java.util.Map;
import kotlin.h.b.n;
import org.greenrobot.eventbus.ThreadMode;

public final class DuetDiscoverPanel extends DetailFragmentPanel implements AnonymousClass2GO {
    public boolean LIZ = true;
    public RelativeLayout LIZIZ;
    public final Crj LJJIZ = 7he.LIZ(C34763iG.LIZ);
    public final long LJJJ = 2000;

    static {
        Covode.recordClassIndex(63732);
    }

    private final C34773iH LJJLIL() {
        return (C34773iH) this.LJJIZ.getValue();
    }

    public final void LIZ(MotionEvent motionEvent) {
    }

    public final boolean LJJLIIIJLLLLLLLZ() {
        return true;
    }

    public final boolean LJJLIIJ() {
        return false;
    }

    public final Map<Integer, Object> getSubscriberEventTypes() {
        Map<Integer, Object> subscriberEventTypes = super.getSubscriberEventTypes();
        subscriberEventTypes.put(201, new Rc9(DuetDiscoverPanel.class, "DuetTabSelectChanged", C34743iE.class, ThreadMode.POSTING, 0, false));
        return subscriberEventTypes;
    }

    public final void LJIIZILJ() {
        super.LJIIZILJ();
        if (LJJIIJZLJL()) {
            TnV tnV = this.LLIFFJFJJ;
            n.LIZIZ(tnV, "");
            if (tnV.isFromDuetMode() && !this.LIZ) {
                LLJ();
            }
        }
    }

    public final void br_() {
        if (!LJJLIL().LIZ.getBoolean("duet_mode_swipe_guide_shown", false)) {
            LJJLIIIJL();
            LJJLIL().LIZ.storeBoolean("duet_mode_swipe_guide_shown", true);
        }
    }

    public final boolean LJJIIJZLJL() {
        String LIZ2 = DuetDiscoverServiceImpl.LIZIZ().LIZ();
        if (LIZ2.hashCode() != -1008505828 || !LIZ2.equals("full_screen")) {
            return super.LJJIIJZLJL();
        }
        if (!this.LIZ) {
            return true;
        }
        return false;
    }

    public final String LJJLIIIJLJLI() {
        if (TextUtils.equals(this.LLIFFJFJJ.getFrom(), "from_duet_mode")) {
            return "duet";
        }
        if (TextUtils.equals(this.LLIFFJFJJ.getFrom(), "from_duet_mode_detail")) {
            return "original";
        }
        return "";
    }

    public final void LJIILLIIL() {
        View view;
        super.LJIILLIIL();
        Fragment bt_ = bt_();
        n.LIZIZ(bt_, "");
        ViewGroup viewGroup = (ViewGroup) bt_.getView();
        if (viewGroup != null) {
            view = viewGroup.findViewById(2131362871);
        } else {
            view = null;
        }
        this.LJJJLZIJ = view;
        View view2 = this.LJJJLZIJ;
        n.LIZIZ(view2, "");
        view2.setVisibility(8);
        View view3 = this.LJJJLZIJ;
        n.LIZIZ(view3, "");
        view3.getLayoutParams().height = 0;
        View view4 = this.LJJJLL;
        n.LIZIZ(view4, "");
        view4.getLayoutParams().height = 0;
    }

    public final void LJJLIIIJL() {
        if (this.LJJJLIIL != null) {
            T3s t3s = this.LJJJLIIL;
            if (t3s == null || t3s.getChildCount() != 0) {
                MNS.LIZ.LIZ();
                if (this.LLJLL == null) {
                    ViewGroup LJJJIL = LJJJIL();
                    if (LJJJIL != null) {
                        T3s t3s2 = this.LJJJLIIL;
                        n.LIZIZ(t3s2, "");
                        String str = this.LLJLIL;
                        n.LIZIZ(str, "");
                        this.LLJLL = new C08622hC(LJJJIL, t3s2, str, true, TextUtils.equals(this.LLIFFJFJJ.getEventType(), "homepage_hot"), C02062Ma.SWIPE_UP_GUIDE);
                    } else {
                        return;
                    }
                }
                C08622hC r0 = this.LLJLL;
                if (r0 != null) {
                    r0.LIZ();
                }
            }
        }
    }

    /* JADX WARNING: type inference failed for: r8v0, types: [android.view.View$OnClickListener, X.3iC] */
    public final void LJIIL() {
        View LIZ2;
        int i;
        MethodCollector.i(10420);
        if (this.LLL != null) {
            Activity activity = this.LLL;
            n.LIZIZ(activity, "");
            if (!activity.isFinishing()) {
                if (bt_() == null) {
                    MethodCollector.o(10420);
                    return;
                } else if (this.LIZIZ != null) {
                    MethodCollector.o(10420);
                    return;
                } else {
                    ViewGroup LJJJIL = LJJJIL();
                    if (LJJJIL == null) {
                        MethodCollector.o(10420);
                        return;
                    }
                    RelativeLayout relativeLayout = new RelativeLayout(this.LLL);
                    LJJJIL.addView(relativeLayout, new ViewGroup.LayoutParams(-1, -1));
                    TnV tnV = this.LLIFFJFJJ;
                    n.LIZIZ(tnV, "");
                    int i2 = 0;
                    if (tnV.isFromDuetMode()) {
                        LIZ2 = 0HH.LIZ(LayoutInflater.from(this.LLL), 2131559514, relativeLayout, false);
                    } else {
                        LIZ2 = 0HH.LIZ(LayoutInflater.from(this.LLL), 2131559515, relativeLayout, false);
                    }
                    View findViewById = LIZ2.findViewById(2131362815);
                    if (findViewById != null) {
                        Qeg findViewById2 = ((ViewGroup) findViewById).findViewById(2131369378);
                        if (findViewById2 != null) {
                            findViewById2.setTuxFont(32);
                            TnV tnV2 = this.LLIFFJFJJ;
                            n.LIZIZ(tnV2, "");
                            if (tnV2.isFromDuetModeDetail()) {
                                i = 2131824097;
                            } else {
                                i = 2131822298;
                            }
                            findViewById2.setText(i);
                        }
                        findViewById.setOnClickListener(new C34723iC(this.LJJJ, this, LJJJIL));
                    }
                    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -2);
                    layoutParams.addRule(12);
                    TnV tnV3 = this.LLIFFJFJJ;
                    n.LIZIZ(tnV3, "");
                    if (!tnV3.isFromDuetModeDetail()) {
                        i2 = (int) HeD.LIZIZ(relativeLayout.getContext(), 40.0f);
                    }
                    layoutParams.bottomMargin = i2;
                    relativeLayout.addView(LIZ2, layoutParams);
                    this.LIZIZ = relativeLayout;
                    MethodCollector.o(10420);
                    return;
                }
            }
        }
        MethodCollector.o(10420);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public DuetDiscoverPanel(TnV tnV) {
        super(tnV);
        M12.LIZ(tnV);
    }

    @ISm
    public final void DuetTabSelectChanged(C34743iE r3) {
        M12.LIZ(r3);
        this.LIZ = r3.LIZ;
        boolean z = r3.LIZ;
        if (z) {
            LJJIIZ();
        } else if (!z) {
            LLIIJI();
        }
    }

    public final void LJI(Aweme aweme) {
        Activity activity = this.LLL;
        if (activity != null) {
            DuetModeCameraServiceImpl.LIZJ().LIZ().LIZ(aweme, activity, LJJLIIIJLJLI());
        }
    }
}
