package com.bytedance.android.live.liveinteract.multicohost.ui.fragment;

import X.6iy;
import X.7he;
import X.9HM;
import X.AnonymousClass0EB;
import X.AnonymousClass0EC;
import X.AnonymousClass0HH;
import X.AnonymousClass12L;
import X.AnonymousClass1CX;
import X.AnonymousClass1MY;
import X.AnonymousClass1TT;
import X.AnonymousClass1UB;
import X.AnonymousClass1UN;
import X.C07930Ul;
import X.C10000b0;
import X.C15040j8;
import X.C18200oE;
import X.C18580oq;
import X.C18860pI;
import X.C18870pJ;
import X.C18880pK;
import X.C18890pL;
import X.C24170xr;
import X.C24290y3;
import X.C42451mF;
import X.C46321sU;
import X.C46331sV;
import X.C50091yZ;
import X.C50101ya;
import X.C50111yb;
import X.C50121yc;
import X.Crj;
import X.FkL;
import X.G2l;
import X.Gzu;
import X.H1f;
import X.HL0;
import X.M12;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.Spannable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.live.liveinteract.multicohost.business.contract.MultiCoHostBeInvitedContract;
import com.bytedance.android.livesdk.livesetting.broadcast.MultiHostPerceptionEnableSetting;
import com.bytedance.android.livesdk.livesetting.linkmic.MtCoHostReplyTimeOutSetting;
import com.bytedance.android.livesdk.model.message.PerceptionDialogInfo;
import com.bytedance.android.livesdk.model.message.common.Text;
import com.bytedance.android.livesdk.model.message.linker.invite_message.InviterRivalExtra;
import com.bytedance.android.livesdk.model.message.linker.invite_message.LinkerInviteContent;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.h.b.n;

public final class MultiCoHostBeInvitedFragment extends MultiCoHostBeInvitedContract.AbsView {
    public static final C18860pI LJII = new C18860pI((byte) 0);
    public View LIZ;
    public LinkerInviteContent LJ;
    public DataChannel LJFF;
    public int LJI;
    public final String LJIIIIZZ;
    public final Crj LJIIIZ;
    public final Crj LJIIJ;
    public final Crj LJIIJJI;
    public final Crj LJIIL;
    public FkL LJIILIIL;
    public final long LJIILJJIL;
    public HashMap LJIILL;

    static {
        Covode.recordClassIndex(7823);
    }

    private final H1f LIZLLL() {
        return (H1f) this.LJIIIZ.getValue();
    }

    private final C46321sU LJFF() {
        return (C46321sU) this.LJIIJJI.getValue();
    }

    public final void LIZ() {
        HashMap hashMap = this.LJIILL;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final AnonymousClass1MY LIZIZ() {
        return (AnonymousClass1MY) this.LJIIJ.getValue();
    }

    public final C46321sU LIZJ() {
        return (C46321sU) this.LJIIL.getValue();
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        LIZ();
    }

    public final void onDestroy() {
        MultiCoHostBeInvitedFragment.super.onDestroy();
        T t = this.LIZJ;
        if (t != null) {
            t.LJIIIIZZ();
        }
        this.LIZJ = null;
    }

    /* JADX WARNING: type inference failed for: r8v0, types: [com.bytedance.android.live.liveinteract.multicohost.ui.fragment.MultiCoHostBeInvitedFragment, androidx.fragment.app.Fragment] */
    public final C15040j8 LJ() {
        String string;
        LinkerInviteContent linkerInviteContent = this.LJ;
        if (linkerInviteContent == null) {
            n.LIZ("");
        }
        InviterRivalExtra inviterRivalExtra = linkerInviteContent.LJIIL.LJII;
        C15040j8 r5 = new C15040j8();
        if (this.LJI == 2) {
            string = C10000b0.LIZ(2131828374, C07930Ul.LIZ(inviterRivalExtra.LJFF, inviterRivalExtra.LJII));
        } else {
            string = getString(2131828375);
        }
        n.LIZIZ(string, "");
        r5.LIZ(string);
        r5.LJI = false;
        return r5;
    }

    public MultiCoHostBeInvitedFragment() {
        this.LJIIIIZZ = "want to join the squad(fixme)";
        this.LJIIIZ = 7he.LIZ(new C50101ya(this));
        this.LJIIJ = 7he.LIZ(new C50121yc(this));
        this.LJIIJJI = 7he.LIZ(new C50111yb(this));
        this.LJIIL = 7he.LIZ(new C50091yZ(this));
        this.LJIILIIL = new FkL();
        this.LJI = 1;
        this.LJIILJJIL = SystemClock.uptimeMillis();
    }

    private final void LJI() {
        this.LJIILIIL.LIZ(C18200oE.class, new AnonymousClass1UB());
        ArrayList arrayList = new ArrayList();
        LinkerInviteContent linkerInviteContent = this.LJ;
        if (linkerInviteContent == null) {
            n.LIZ("");
        }
        InviterRivalExtra inviterRivalExtra = linkerInviteContent.LJIIL.LJII;
        n.LIZIZ(inviterRivalExtra, "");
        arrayList.add(new C18200oE(inviterRivalExtra, true));
        if (this.LJI == 1) {
            LinkerInviteContent linkerInviteContent2 = this.LJ;
            if (linkerInviteContent2 == null) {
                n.LIZ("");
            }
            List<InviterRivalExtra> list = linkerInviteContent2.LJIIL.LJIIIIZZ;
            if (list != null) {
                for (InviterRivalExtra inviterRivalExtra2 : list) {
                    n.LIZIZ(inviterRivalExtra2, "");
                    arrayList.add(new C18200oE(inviterRivalExtra2, false));
                }
            }
        }
        this.LJIILIIL.LIZ(arrayList);
        this.LJIILIIL.notifyDataSetChanged();
    }

    public /* synthetic */ MultiCoHostBeInvitedFragment(byte b) {
        this();
    }

    public static final /* synthetic */ View LIZ(MultiCoHostBeInvitedFragment multiCoHostBeInvitedFragment) {
        View view = multiCoHostBeInvitedFragment.LIZ;
        if (view == null) {
            n.LIZ("");
        }
        return view;
    }

    public final void LIZ(long j) {
        if (this.mStatusViewValid) {
            LIZIZ(j);
        }
    }

    /* JADX WARNING: type inference failed for: r6v0, types: [com.bytedance.android.live.liveinteract.multicohost.ui.fragment.MultiCoHostBeInvitedFragment, androidx.fragment.app.Fragment] */
    private final void LIZIZ(long j) {
        LJFF().setText((CharSequence) Gzu.LIZ(getString(2131828355), new Object[]{Integer.valueOf((int) j)}));
        if (j == 0) {
            int i = this.LJI;
            if (i == 1) {
                LIZIZ(5);
            } else if (i == 2) {
                LIZ(5);
            }
        }
    }

    public final void LIZ(int i) {
        if (this.mStatusViewValid) {
            boolean z = true;
            if (i != 1) {
                z = false;
            }
            LIZ(z);
            LIZ(this.LJI, i);
            AnonymousClass1TT r2 = (AnonymousClass1TT) this.LIZJ;
            if (r2 != null) {
                LinkerInviteContent linkerInviteContent = this.LJ;
                if (linkerInviteContent == null) {
                    n.LIZ("");
                }
                r2.LIZIZ(linkerInviteContent, i);
            }
            C18580oq.LIZ("MultiCoHostPrivateAccountDialog");
            this.LIZIZ.dismiss();
        }
    }

    public final void LIZIZ(int i) {
        if (this.mStatusViewValid) {
            boolean z = true;
            if (i != 1) {
                z = false;
            }
            LIZ(z);
            LIZ(this.LJI, i);
            AnonymousClass1TT r2 = (AnonymousClass1TT) this.LIZJ;
            if (r2 != null) {
                LinkerInviteContent linkerInviteContent = this.LJ;
                if (linkerInviteContent == null) {
                    n.LIZ("");
                }
                r2.LIZ(linkerInviteContent, i);
            }
            C18580oq.LIZ("MultiCoHostPrivateAccountDialog");
            this.LIZIZ.dismiss();
        }
    }

    private final void LIZ(boolean z) {
        boolean z2;
        boolean isChecked = LIZIZ().isChecked();
        LinkerInviteContent linkerInviteContent = this.LJ;
        if (linkerInviteContent == null) {
            n.LIZ("");
        }
        List<InviterRivalExtra> list = linkerInviteContent.LJIIL.LJIIIIZZ;
        n.LIZIZ(list, "");
        ArrayList arrayList = new ArrayList(9HM.LIZ(list, 10));
        for (InviterRivalExtra inviterRivalExtra : list) {
            arrayList.add(Long.valueOf(inviterRivalExtra.LJIIJJI));
        }
        List list2 = arrayList;
        C24170xr r4 = C24170xr.LIZLLL;
        if (this.LJI == 2) {
            z2 = true;
        } else {
            z2 = false;
        }
        LinkerInviteContent linkerInviteContent2 = this.LJ;
        if (linkerInviteContent2 == null) {
            n.LIZ("");
        }
        r4.LIZ(z2, z, isChecked, linkerInviteContent2.LIZ, (List<Long>) list2);
    }

    private final void LIZ(int i, int i2) {
        boolean isChecked = LIZIZ().isChecked();
        int i3 = i2;
        if (i != 1) {
            if (i == 2) {
                if (i3 == 1) {
                    C42451mF LIZ2 = C42451mF.LIZ.LIZ();
                    LinkerInviteContent linkerInviteContent = this.LJ;
                    if (linkerInviteContent == null) {
                        n.LIZ("");
                    }
                    LIZ2.LIZIZ(linkerInviteContent.LIZ, this.LJIILJJIL);
                    return;
                }
                C42451mF LIZ3 = C42451mF.LIZ.LIZ();
                LinkerInviteContent linkerInviteContent2 = this.LJ;
                if (linkerInviteContent2 == null) {
                    n.LIZ("");
                }
                LIZ3.LIZIZ(linkerInviteContent2.LIZ, i3, isChecked, this.LJIILJJIL);
            }
        } else if (i3 == 1) {
            C42451mF LIZ4 = C42451mF.LIZ.LIZ();
            LinkerInviteContent linkerInviteContent3 = this.LJ;
            if (linkerInviteContent3 == null) {
                n.LIZ("");
            }
            LIZ4.LIZ(linkerInviteContent3.LIZ, this.LJIILJJIL);
        } else {
            C42451mF LIZ5 = C42451mF.LIZ.LIZ();
            LinkerInviteContent linkerInviteContent4 = this.LJ;
            if (linkerInviteContent4 == null) {
                n.LIZ("");
            }
            LIZ5.LIZ(linkerInviteContent4.LIZ, i3, isChecked, this.LJIILJJIL);
        }
    }

    /* JADX WARNING: type inference failed for: r11v0, types: [com.bytedance.android.live.liveinteract.cohost.business.contract.InteractDialogFragmentBaseContract$AbsView, com.bytedance.android.live.liveinteract.multicohost.ui.fragment.MultiCoHostBeInvitedFragment, androidx.fragment.app.Fragment] */
    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        User owner;
        boolean z;
        AnonymousClass1TT r2;
        Text text;
        M12.LIZ(layoutInflater);
        View LIZ2 = AnonymousClass0HH.LIZ(layoutInflater, 2131561767, viewGroup, false);
        n.LIZIZ(LIZ2, "");
        this.LIZ = LIZ2;
        if (MultiHostPerceptionEnableSetting.INSTANCE.getValue()) {
            View view = this.LIZ;
            if (view == null) {
                n.LIZ("");
            }
            ViewGroup viewGroup2 = (ViewGroup) view.findViewById(2131371601);
            View view2 = this.LIZ;
            if (view2 == null) {
                n.LIZ("");
            }
            C46331sV r4 = (C46331sV) view2.findViewById(2131371602);
            LinkerInviteContent linkerInviteContent = this.LJ;
            if (linkerInviteContent == null) {
                n.LIZ("");
            }
            PerceptionDialogInfo perceptionDialogInfo = linkerInviteContent.LJIILL;
            if (!(perceptionDialogInfo == null || (text = perceptionDialogInfo.LIZJ) == null)) {
                Spannable LIZ3 = HL0.LIZ(text, text.LIZIZ);
                G2l.LIZIZ(viewGroup2);
                n.LIZIZ(r4, "");
                r4.setText(LIZ3);
                LinkerInviteContent linkerInviteContent2 = this.LJ;
                if (linkerInviteContent2 == null) {
                    n.LIZ("");
                }
                C24290y3.LIZ(linkerInviteContent2.LJIILLIIL);
            }
        }
        H1f LIZLLL = LIZLLL();
        getContext();
        LIZLLL.setLayoutManager(new LinearLayoutManager());
        if (LIZLLL().getItemAnimator() instanceof AnonymousClass1CX) {
            AnonymousClass0EB itemAnimator = LIZLLL().getItemAnimator();
            Objects.requireNonNull(itemAnimator, "null cannot be cast to non-null type androidx.recyclerview.widget.SimpleItemAnimator");
            ((AnonymousClass1CX) itemAnimator).LJIIL = false;
        }
        LIZLLL().setAdapter(this.LJIILIIL);
        AnonymousClass0EB itemAnimator2 = LIZLLL().getItemAnimator();
        if (itemAnimator2 instanceof AnonymousClass1CX) {
            ((AnonymousClass1CX) itemAnimator2).LJIIL = false;
        }
        LIZLLL().LIZIZ((AnonymousClass0EC) new AnonymousClass1UN(C10000b0.LIZ(8.0f)));
        if (this.LJI == 2) {
            LIZIZ().setText(C10000b0.LIZ(2131828373));
            LinkerInviteContent linkerInviteContent3 = this.LJ;
            if (linkerInviteContent3 == null) {
                n.LIZ("");
            }
            InviterRivalExtra inviterRivalExtra = linkerInviteContent3.LJIIL.LJII;
            if (!(inviterRivalExtra == null || (r2 = (AnonymousClass1TT) this.LIZJ) == null)) {
                r2.LIZ(inviterRivalExtra.LJIIJJI);
            }
        } else {
            Room LJI2 = AnonymousClass12L.LJI(this.LJFF);
            if (!(LJI2 == null || (owner = LJI2.getOwner()) == null)) {
                long id = owner.getId();
                AnonymousClass1TT r0 = (AnonymousClass1TT) this.LIZJ;
                if (r0 != null) {
                    r0.LIZ(id);
                }
            }
        }
        LJI();
        LJFF().setOnClickListener(new C18870pJ(this));
        LIZJ().setOnClickListener(new C18880pK(this));
        LIZIZ().setOnCheckedChangeListener(new C18890pL(this));
        LinkerInviteContent linkerInviteContent4 = this.LJ;
        if (linkerInviteContent4 == null) {
            n.LIZ("");
        }
        List LIZ4 = 6iy.LIZ(Long.valueOf(linkerInviteContent4.LIZ));
        C24170xr r5 = C24170xr.LIZLLL;
        if (this.LJI == 2) {
            z = true;
        } else {
            z = false;
        }
        LinkerInviteContent linkerInviteContent5 = this.LJ;
        if (linkerInviteContent5 == null) {
            n.LIZ("");
        }
        long j = linkerInviteContent5.LIZ;
        M12.LIZ(LIZ4);
        HashMap hashMap = new HashMap();
        r5.LIZ(hashMap, z, j, LIZ4);
        hashMap.put("time_stamp", String.valueOf(C24170xr.LIZIZ));
        C24170xr.LIZ("livesdk_connected_popup_show", (Map<String, String>) hashMap);
        LIZIZ(((long) MtCoHostReplyTimeOutSetting.INSTANCE.getValue()) - 1);
        View view3 = this.LIZ;
        if (view3 == null) {
            n.LIZ("");
        }
        return view3;
    }
}
