package com.ss.android.ugc.aweme.duet.ui;

import X.0AA;
import X.1B1;
import X.2GO;
import X.2K7;
import X.2xd;
import X.30v;
import X.3af;
import X.7he;
import X.8qM;
import X.BG9;
import X.BL8;
import X.BMB;
import X.BND;
import X.BNF;
import X.BNG;
import X.BNH;
import X.BNI;
import X.BNL;
import X.BNM;
import X.BNN;
import X.BNO;
import X.BNP;
import X.BNQ;
import X.BNR;
import X.BNS;
import X.BNT;
import X.BNV;
import X.BNW;
import X.BNY;
import X.BQM;
import X.C2099Amt;
import X.C3338BGk;
import X.C3339BGl;
import X.C3444BKm;
import X.C3503BMt;
import X.C3512BNc;
import X.C3555BOt;
import X.Crj;
import X.DcP;
import X.LeS;
import X.Lea;
import X.LsC;
import X.M12;
import X.OQg;
import X.OQh;
import X.T1t;
import X.T5D;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.bytedance.tux.sheet.sheet.TuxSheet;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.challenge.ui.BaseDetailFragment;
import com.ss.android.ugc.aweme.challenge.ui.DetailAwemeListFragment;
import com.ss.android.ugc.aweme.detail.AbstractDetailFragment;
import com.ss.android.ugc.aweme.services.NetworkStandardUIServiceImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class DuetDetailFragment extends BaseDetailFragment implements C3339BGl, 2GO {
    public static final C3512BNc LJIIL = new C3512BNc((byte) 0);
    public String LIZLLL;
    public String LJ;
    public String LJIIIZ;
    public DuetAwemeListFragment LJIIJ;
    public C3338BGk LJIIJJI;
    public String LJIILIIL;
    public String LJIILJJIL = "";
    public String LJIILL = "";
    public final Crj LJIIZILJ = 7he.LIZ(new BNS(this));
    public float LJIJ;
    public float LJIJI;
    public boolean LJIJJ;
    public final Crj LJIJJLI = 7he.LIZ(new BND(this));
    public final Crj LJIL = 7he.LIZ(new BNM(this));
    public final Crj LJJJJI = 7he.LIZ(new BNQ(this));
    public final Crj LJJJJIZL = 7he.LIZ(new BNL(this));
    public final Crj LJJJJJ = 7he.LIZ(new BNP(this));
    public final Crj LJJJJJL = 7he.LIZ(new BNN(this));
    public final Crj LJJJJL = 7he.LIZ(new BNO(this));
    public SparseArray LJJJJLI;

    static {
        Covode.recordClassIndex(67746);
    }

    private final BNV LJ() {
        return (BNV) this.LJIIZILJ.getValue();
    }

    private final BG9 LJFF() {
        return (BG9) this.LJIJJLI.getValue();
    }

    private final View LJI() {
        return (View) this.LJIL.getValue();
    }

    private final TextView LJII() {
        return (TextView) this.LJJJJI.getValue();
    }

    private final OQg LJIIIIZZ() {
        return (OQg) this.LJJJJJ.getValue();
    }

    private final View LJIIJJI() {
        return (View) this.LJJJJL.getValue();
    }

    public final T5D LIZ() {
        return (T5D) this.LJJJJJL.getValue();
    }

    public final String LIZJ(int i) {
        return "duet_page";
    }

    public final int LJIIIZ() {
        return 2131561473;
    }

    public final boolean LJJIJIIJI() {
        return false;
    }

    public final String LJIIJ() {
        String str = this.LIZLLL;
        if (str == null) {
            return "";
        }
        return str;
    }

    public static boolean LJIILJJIL() {
        try {
            return 2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        SparseArray sparseArray = this.LJJJJLI;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final void LIZLLL() {
        if (NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(false).isStandardUIEnable()) {
            if (LIZ().getVisibility() != 0) {
                LIZ((Throwable) null);
            }
            LJFF().LJ = new BNR(this);
            LJFF().LIZ();
            LJIIIIZZ().LIZ();
            8qM r0 = 2K7.LIZ;
            n.LIZIZ(r0, "");
            if (r0.LIZIZ == DcP.AVAILABLE) {
                LJFF().LIZJ = true;
                C3338BGk bGk = this.LJIIJJI;
                if (bGk == null) {
                    n.LIZ("");
                }
                bGk.LIZ(this.LJIIIZ);
                return;
            }
            return;
        }
        LJIIIIZZ().setVisibility(0);
        getContext();
        if (!LJIILJJIL()) {
            3af r1 = new 3af(this);
            r1.LJ(2131827476);
            3af.LIZ(r1);
            OQg LJIIIIZZ = LJIIIIZZ();
            OQh oQh = new OQh();
            30v.LIZ(oQh, new BNH(this));
            LJIIIIZZ.setStatus(oQh);
            return;
        }
        LJIIIIZZ().LIZ();
        C3338BGk bGk2 = this.LJIIJJI;
        if (bGk2 == null) {
            n.LIZ("");
        }
        bGk2.LIZ(this.LJIIIZ);
    }

    public final 1B1 LJIILIIL() {
        String str;
        this.LJJIJIL = new ArrayList();
        this.LJJIJL = new ArrayList();
        this.LIZ = new ArrayList();
        0AA childFragmentManager = getChildFragmentManager();
        StringBuilder sb = new StringBuilder();
        sb.append(AbstractDetailFragment.LJJ);
        boolean z = false;
        sb.append(0);
        DuetAwemeListFragment LIZ = childFragmentManager.LIZ(sb.toString());
        if (!(LIZ instanceof DuetAwemeListFragment)) {
            BMB bmb = DuetAwemeListFragment.LJJJIL;
            String str2 = this.LJIIIZ;
            if (str2 == null) {
                n.LIZIZ();
            }
            String str3 = this.LIZLLL;
            String str4 = this.LJIILJJIL;
            String str5 = this.LJIILL;
            String str6 = this.LJIIIZ;
            if (str6 == null) {
                n.LIZIZ();
            }
            C3503BMt bMt = new C3503BMt(str6);
            M12.LIZ("duet_page", str2, "", str4, str5, bMt);
            LIZ = new DuetAwemeListFragment();
            Bundle bundle = new Bundle();
            bundle.putInt(DuetAwemeListFragment.LJJIJLIJ, 24);
            bundle.putString(DuetAwemeListFragment.LJJIL, "duet_page");
            bundle.putString(DuetAwemeListFragment.LJJIZ, str2);
            String[] strArr = new String[2];
            strArr[0] = bmb.LIZ(str2);
            if (str3 != null) {
                str = bmb.LIZ(str3);
            } else {
                str = null;
            }
            strArr[1] = str;
            bundle.putString("top_aweme_ids", Lea.LIZ(LeS.LIZIZ(strArr), ", ", "[", "]", 0, (CharSequence) null, (LsC) null, 56));
            bundle.putBoolean("extra_challenge_is_hashtag", false);
            bundle.putString("extra_challenge_hashtag_name", "");
            bundle.putString(DuetAwemeListFragment.LJJJ, str4);
            bundle.putString(DuetAwemeListFragment.LJJJI, str5);
            LIZ.setArguments(bundle);
            LIZ.LJJIJIL = bMt;
            DetailAwemeListFragment detailAwemeListFragment = LIZ;
            if (this.LJJIJIIJI == 0) {
                z = true;
            }
            detailAwemeListFragment.LJJIIJ = z;
            detailAwemeListFragment.LJJIIJZLJL = true;
        }
        Objects.requireNonNull(LIZ, "null cannot be cast to non-null type com.ss.android.ugc.aweme.duet.ui.DuetAwemeListFragment");
        this.LJIIJ = LIZ;
        List<C3444BKm> list = this.LJJIJIL;
        DuetAwemeListFragment duetAwemeListFragment = this.LJIIJ;
        if (duetAwemeListFragment == null) {
            n.LIZ("");
        }
        list.add(duetAwemeListFragment);
        List<AmeBaseFragment> list2 = this.LJJIJL;
        DuetAwemeListFragment duetAwemeListFragment2 = this.LJIIJ;
        if (duetAwemeListFragment2 == null) {
            n.LIZ("");
        }
        list2.add(duetAwemeListFragment2);
        this.LIZ.add(24);
        return new BQM(getChildFragmentManager(), this.LJJIJL, this.LIZ);
    }

    public static final /* synthetic */ DuetAwemeListFragment LIZ(DuetDetailFragment duetDetailFragment) {
        DuetAwemeListFragment duetAwemeListFragment = duetDetailFragment.LJIIJ;
        if (duetAwemeListFragment == null) {
            n.LIZ("");
        }
        return duetAwemeListFragment;
    }

    public final C3555BOt LIZ(ViewGroup viewGroup) {
        M12.LIZ(viewGroup);
        Context requireContext = requireContext();
        n.LIZIZ(requireContext, "");
        return new T1t(requireContext, viewGroup);
    }

    public final void LIZ(Bundle bundle) {
        String str;
        String str2;
        String str3;
        String str4;
        String string;
        String str5 = "";
        if (bundle == null || (str = bundle.getString("enter_method")) == null) {
            str = str5;
        }
        this.LJIILIIL = str;
        if (bundle == null || (str2 = bundle.getString("enter_from")) == null) {
            str2 = str5;
        }
        this.LJIILJJIL = str2;
        String str6 = null;
        if (bundle != null) {
            str3 = bundle.getString("id");
        } else {
            str3 = null;
        }
        this.LIZLLL = str3;
        if (bundle != null) {
            str6 = bundle.getString("author_id");
        }
        this.LJ = str6;
        if (bundle == null || (str4 = bundle.getString("origin_item_id")) == null) {
            str4 = str5;
        }
        this.LJIIIZ = str4;
        if (!(bundle == null || (string = bundle.getString("from_group_id")) == null)) {
            str5 = string;
        }
        this.LJIILL = str5;
    }

    public final void LIZ(BNW bnw) {
        M12.LIZ(bnw);
        if (aq_()) {
            if (bnw.LIZJ == null || TextUtils.isEmpty(bnw.LIZJ.getUri())) {
                LJIIIIZZ().setVisibility(0);
                OQh oQh = new OQh();
                oQh.LIZ(2xd.LIZ(BNF.LIZ));
                String string = getString(2131834754);
                n.LIZIZ(string, "");
                oQh.LIZ(string);
                LJIIIIZZ().setStatus(oQh);
                return;
            }
            if (NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(false).isStandardUIEnable()) {
                LIZ().setVisibility(0);
                LIZ().setRefreshing(false);
                LJFF().LIZIZ();
            }
            this.LJIJJ = true;
            LJIIIIZZ().setVisibility(8);
            LJ().LIZ(bnw);
            BNY LIZ = BNY.Companion.LIZ(bnw.LJ);
            if (LIZ == null) {
                return;
            }
            if (LIZ == BNY.REMIND_DUET_NOT_ALLOWED || LIZ == BNY.REMIND_SOUND_NOT_READY) {
                LJI().setVisibility(8);
                dh_();
                return;
            }
            LJI().setVisibility(0);
        }
    }

    public final void LIZ(Exception exc) {
        M12.LIZ(exc);
        if (!aq_()) {
            return;
        }
        if (NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(false).isStandardUIEnable()) {
            LJFF().LJ = new BNI(this, exc);
            LJFF().LIZ(exc);
            return;
        }
        3af r1 = new 3af(this);
        r1.LJ(2131827476);
        3af.LIZ(r1);
        if (this.LJIJJ) {
            LJIIIIZZ().setVisibility(8);
            return;
        }
        LJIIIIZZ().setVisibility(0);
        OQg LJIIIIZZ = LJIIIIZZ();
        OQh oQh = new OQh();
        30v.LIZ(oQh, new BNG(this));
        LJIIIIZZ.setStatus(oQh);
    }

    public final void LIZ(Throwable th) {
        C2099Amt.LIZ(LJIIIIZZ(), "DuetDetail", th, new BNT(this));
        LJIIIIZZ().setVisibility(0);
    }

    public final void LIZIZ(int i, int i2) {
        Integer num;
        int i3;
        super.LIZIZ(i, i2);
        int i4 = 0;
        float f = 0.0f;
        if (this.LJIJ == 0.0f && LJII().getVisibility() == 0) {
            TextView LJII = LJII();
            if (LJII != null) {
                num = Integer.valueOf(LJII.getBottom());
            } else {
                num = null;
            }
            int intValue = num.intValue();
            if (this.LJJIII != null) {
                View view = this.LJJIII;
                n.LIZIZ(view, "");
                i3 = view.getBottom();
            } else {
                i3 = 0;
            }
            this.LJIJ = (float) (intValue - i3);
        }
        if (this.LJIJI == 0.0f) {
            int bottom = ((View) this.LJJJJIZL.getValue()).getBottom();
            if (this.LJJIII != null) {
                View view2 = this.LJJIII;
                n.LIZIZ(view2, "");
                i4 = view2.getBottom();
            }
            this.LJIJI = (float) (bottom - i4);
        }
        float f2 = this.LJIJ;
        float f3 = (((float) i) - f2) / (this.LJIJI - f2);
        if (((double) f3) > 0.2d) {
            f = f3;
            if (f > 1.0f) {
                f = 1.0f;
            }
        }
        View view3 = this.LJJIII;
        n.LIZIZ(view3, "");
        view3.setAlpha(f);
    }

    public final void LIZ(TuxSheet tuxSheet, float f) {
        M12.LIZ(tuxSheet);
        super.LIZ(tuxSheet, f);
        if (NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(false).isStandardUIEnable() && BL8.LIZJ) {
            ViewGroup.LayoutParams layoutParams = LJIIIIZZ().getLayoutParams();
            Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin = (int) ((1.0f - f) * 750.0f);
            if ((f == 1.0f || f == 0.0f) && LIZ().getVisibility() != 0) {
                LIZ((Throwable) null);
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x0083  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0099  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x00f6  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void onViewCreated(android.view.View r7, android.os.Bundle r8) {
        /*
            r6 = this;
            X.M12.LIZ(r7)
            X.BNV r0 = r6.LJ()
            r0.LIZ((android.view.View) r7)
            super.onViewCreated(r7, r8)
            r5 = 0
            com.ss.android.ugc.aweme.net.ui.INetworkStandardUIService r0 = com.ss.android.ugc.aweme.services.NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(r5)
            boolean r0 = r0.isStandardUIEnable()
            r4 = 0
            if (r0 == 0) goto L_0x0104
            X.T5D r1 = r6.LIZ()
            r0 = 8
            r1.setVisibility(r0)
            X.T5D r1 = r6.LIZ()
            X.BNC r0 = new X.BNC
            r0.<init>(r6)
            r1.setOnRefreshListener(r0)
        L_0x002e:
            android.view.View r1 = r6.LJI()
            X.3cu r0 = new X.3cu
            r0.<init>(r6)
            r1.setOnClickListener(r0)
            X.BGk r1 = new X.BGk
            r1.<init>()
            r6.LJIIJJI = r1
            java.lang.String r3 = ""
            r0 = r6
            r1.a_(r0)
            android.util.SparseArray r0 = r6.LJJJJLI
            if (r0 != 0) goto L_0x0052
            android.util.SparseArray r0 = new android.util.SparseArray
            r0.<init>()
            r6.LJJJJLI = r0
        L_0x0052:
            android.util.SparseArray r0 = r6.LJJJJLI
            r2 = 2131362572(0x7f0a030c, float:1.8344928E38)
            java.lang.Object r1 = r0.get(r2)
            android.view.View r1 = (android.view.View) r1
            if (r1 != 0) goto L_0x0101
            android.view.View r0 = r6.getView()
            if (r0 != 0) goto L_0x00f8
        L_0x0065:
            X.IxE r4 = (X.IxE) r4
            X.BNK r0 = new X.BNK
            r0.<init>(r6)
            r4.setOnClickListener(r0)
            com.ss.android.ugc.aweme.net.ui.INetworkStandardUIService r0 = com.ss.android.ugc.aweme.services.NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(r5)
            boolean r0 = r0.isStandardUIEnable()
            if (r0 == 0) goto L_0x00f2
            boolean r0 = r6.LJJIL
            if (r0 == 0) goto L_0x00f2
            android.content.Context r4 = r6.getContext()
            if (r4 != 0) goto L_0x0086
            kotlin.h.b.n.LIZIZ()
        L_0x0086:
            kotlin.h.b.n.LIZIZ(r4, r3)
            android.content.res.Resources r3 = r4.getResources()
            java.lang.String r2 = "status_bar_height"
            java.lang.String r1 = "dimen"
            java.lang.String r0 = "android"
            int r1 = r3.getIdentifier(r2, r1, r0)
            if (r1 <= 0) goto L_0x00f6
            android.content.res.Resources r0 = r4.getResources()
            int r4 = r0.getDimensionPixelSize(r1)
        L_0x00a1:
            android.content.res.Resources r1 = r6.getResources()
            r0 = 2131166326(0x7f070476, float:1.7946894E38)
            float r3 = r1.getDimension(r0)
            android.view.View r0 = r6.LJIIJJI()
            android.view.ViewGroup$LayoutParams r0 = r0.getLayoutParams()
            r0.height = r4
            android.view.View r1 = r6.LJIIJJI()
            r0 = 1065353216(0x3f800000, float:1.0)
            r1.setAlpha(r0)
            X.OQg r0 = r6.LJIIIIZZ()
            android.view.ViewGroup$LayoutParams r1 = r0.getLayoutParams()
            java.lang.String r2 = "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams"
            java.util.Objects.requireNonNull(r1, r2)
            android.view.ViewGroup$MarginLayoutParams r1 = (android.view.ViewGroup.MarginLayoutParams) r1
            float r0 = (float) r4
            float r0 = r0 + r3
            int r0 = (int) r0
            r1.topMargin = r0
            com.ss.android.ugc.aweme.net.ui.INetworkStandardUIService r0 = com.ss.android.ugc.aweme.services.NetworkStandardUIServiceImpl.createINetworkStandardUIServicebyMonsterPlugin(r5)
            boolean r0 = r0.isStandardUIEnable()
            if (r0 == 0) goto L_0x00f2
            boolean r0 = X.BL8.LIZJ
            if (r0 == 0) goto L_0x00f2
            X.OQg r0 = r6.LJIIIIZZ()
            android.view.ViewGroup$LayoutParams r1 = r0.getLayoutParams()
            java.util.Objects.requireNonNull(r1, r2)
            android.view.ViewGroup$MarginLayoutParams r1 = (android.view.ViewGroup.MarginLayoutParams) r1
            r0 = 750(0x2ee, float:1.051E-42)
            r1.bottomMargin = r0
        L_0x00f2:
            r6.LIZLLL()
            return
        L_0x00f6:
            r4 = 0
            goto L_0x00a1
        L_0x00f8:
            android.view.View r1 = r0.findViewById(r2)
            android.util.SparseArray r0 = r6.LJJJJLI
            r0.put(r2, r1)
        L_0x0101:
            r4 = r1
            goto L_0x0065
        L_0x0104:
            X.T5D r1 = r6.LIZ()
            X.BbM r0 = X.C3932BbM.NONE
            r1.setOverScrollMode(r0)
            X.T5D r1 = r6.LIZ()
            X.40q r0 = X.40q.NONE
            r1.setScrollMode(r0)
            X.T5D r0 = r6.LIZ()
            r0.setNestedHeader(r4)
            goto L_0x002e
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.duet.ui.DuetDetailFragment.onViewCreated(android.view.View, android.os.Bundle):void");
    }
}
