package com.bytedance.android.livesdk.moderator;

import X.0HH;
import X.0cm;
import X.0dh;
import X.15l;
import X.15m;
import X.16A;
import X.1sU;
import X.2K7;
import X.7vl;
import X.9Y3;
import X.C0251FYr;
import X.C0252FYs;
import X.C0392Fec;
import X.C0947FtE;
import X.C0948FtF;
import X.C0950FtH;
import X.C0951FtI;
import X.C0952FtJ;
import X.C0953FtK;
import X.C0955FtM;
import X.C0956FtN;
import X.C0957FtO;
import X.C0958FtP;
import X.C0959FtQ;
import X.C0960FtR;
import X.C0989Ftu;
import X.C1056Fuz;
import X.C1063Fv6;
import X.C1313Fz8;
import X.C1430G2l;
import X.C1612G9l;
import X.C2675Gg0;
import X.C3491GtA;
import X.Crj;
import X.GSF;
import X.Lea;
import X.M12;
import X.Ql4;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.android.live.usermanage.IUserManageService;
import com.bytedance.android.livesdk.chatroom.ui.SSLinearLayoutManager;
import com.bytedance.android.livesdk.livesetting.roomfunction.LiveModeratorPerceptionSetting;
import com.bytedance.android.livesdk.ui.BaseFragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import kotlin.h.b.n;

public final class ModeratorListFragment extends BaseFragment {
    public static final C0959FtQ LIZJ = new C0959FtQ((byte) 0);
    public int LIZ = 10;
    public C0392Fec LIZIZ;
    public final Crj LIZLLL = 7vl.LIZ(new C0947FtE(this));
    public final Crj LJ = 7vl.LIZ(new C0948FtF(this));
    public final C0953FtK LJFF = new C0953FtK(this);
    public HashMap LJI;

    static {
        Covode.recordClassIndex(19612);
    }

    private final long LJ() {
        return ((Number) this.LIZLLL.getValue()).longValue();
    }

    public final boolean LIZ() {
        return ((Boolean) this.LJ.getValue()).booleanValue();
    }

    public final View LIZIZ(int i) {
        if (this.LJI == null) {
            this.LJI = new HashMap();
        }
        View view = (View) this.LJI.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJI.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

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

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        HashMap hashMap = this.LJI;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final List<16A> LIZIZ() {
        List<16A> list;
        DataChannel LIZ2 = GSF.LIZ((Fragment) this);
        if (LIZ2 == null || (list = (List) LIZ2.LIZIZ(C1063Fv6.class)) == null) {
            return new ArrayList();
        }
        return list;
    }

    public final void LIZJ() {
        C1430G2l.LIZIZ(LIZIZ(2131362942));
        ((FrameLayout) LIZIZ(2131362942)).setOnClickListener(new C0956FtN(this));
    }

    public final void LIZLLL() {
        getContext();
        if (!LJFF()) {
            C1313Fz8.LIZ(getContext(), 2131829752);
            return;
        }
        LIZIZ(2131369718).setStatus(0);
        0cm.LIZ(IUserManageService.class).fetchAdminList(this.LJFF, LJ());
    }

    public static final /* synthetic */ C0392Fec LIZ(ModeratorListFragment moderatorListFragment) {
        C0392Fec fec = moderatorListFragment.LIZIZ;
        if (fec == null) {
            n.LIZ("");
        }
        return fec;
    }

    public final void LIZ(int i) {
        if (LIZ()) {
            C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_moderator_page_show");
            LIZ2.LIZ(GSF.LIZ((Fragment) this));
            LIZ2.LIZ("moderator_number", i);
            LIZ2.LIZLLL();
        }
    }

    public final LayoutInflater onGetLayoutInflater(Bundle bundle) {
        LayoutInflater cloneInContext = ModeratorListFragment.super.onGetLayoutInflater(bundle).cloneInContext(0dh.LIZ(getActivity()));
        n.LIZIZ(cloneInContext, "");
        return cloneInContext;
    }

    public static View LIZ(LayoutInflater layoutInflater) {
        MethodCollector.i(7011);
        if (9Y3.LIZ(9Y3.LIZ(), true, "tiktok_tux_text_view_opt", false) && layoutInflater != null && layoutInflater.getFactory() == null && layoutInflater.getFactory2() == null) {
            try {
                layoutInflater.setFactory(new Ql4());
            } catch (Exception unused) {
                View inflate = layoutInflater.inflate(2131561526, (ViewGroup) null);
                MethodCollector.o(7011);
                return inflate;
            }
        }
        View inflate2 = layoutInflater.inflate(2131561526, (ViewGroup) null);
        MethodCollector.o(7011);
        return inflate2;
    }

    public final void LIZ(List<16A> list) {
        DataChannel LIZ2 = GSF.LIZ((Fragment) this);
        if (LIZ2 != null) {
            LIZ2.LIZIZ(C1063Fv6.class, list);
        }
    }

    public final void onEvent(C0960FtR ftR) {
        if (ftR != null) {
            List<16A> LIZIZ2 = LIZIZ();
            ArrayList arrayList = new ArrayList();
            for (T next : LIZIZ2) {
                if (((16A) next).LIZ != ftR.LIZIZ) {
                    arrayList.add(next);
                }
            }
            LIZ((List<16A>) Lea.LJII(arrayList));
            if (isViewValid() && !ftR.LIZ) {
                C0392Fec fec = this.LIZIZ;
                if (fec == null) {
                    n.LIZ("");
                }
                fec.LIZ(ftR.LIZIZ);
                C0392Fec fec2 = this.LIZIZ;
                if (fec2 == null) {
                    n.LIZ("");
                }
                if (fec2.getItemCount() == 0) {
                    LIZIZ(2131369718).setStatus(1);
                }
            }
        }
    }

    public final void LIZ(boolean z) {
        String str;
        DataChannel LIZ2 = GSF.LIZ((Fragment) this);
        if (LIZ2 != null) {
            C0989Ftu ftu = C0989Ftu.MANAGE_MODERATOR;
            ftu.next();
            LIZ2.LIZIZ(C1056Fuz.class, ftu);
        }
        C3491GtA LIZ3 = C3491GtA.LJFF.LIZ("livesdk_add_moderator_click");
        LIZ3.LIZ(GSF.LIZ((Fragment) this));
        if (z) {
            str = "add_icon";
        } else {
            str = "add_button";
        }
        LIZ3.LIZ("click_position", str);
        LIZ3.LIZLLL();
    }

    /* JADX WARNING: type inference failed for: r0v22, types: [android.view.View, X.G9l] */
    public final void onViewCreated(View view, Bundle bundle) {
        int i;
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        ((FrameLayout) LIZIZ(2131369721)).setOnClickListener(new C0950FtH(this));
        if (LIZ()) {
            if (LiveModeratorPerceptionSetting.INSTANCE.newStyle()) {
                C1430G2l.LIZIZ(LIZIZ(2131362979));
                ((FrameLayout) LIZIZ(2131362979)).setOnClickListener(new C0958FtP(this));
            } else {
                LIZJ();
            }
        }
        this.LIZIZ = new C0392Fec(GSF.LIZ((Fragment) this), "moderator_panel", LJ(), LIZ());
        RecyclerView LIZIZ2 = LIZIZ(2131369716);
        n.LIZIZ(LIZIZ2, "");
        getContext();
        LIZIZ2.setLayoutManager(new SSLinearLayoutManager(1));
        RecyclerView LIZIZ3 = LIZIZ(2131369716);
        n.LIZIZ(LIZIZ3, "");
        C0392Fec fec = this.LIZIZ;
        if (fec == null) {
            n.LIZ("");
        }
        LIZIZ3.setAdapter(fec);
        LIZLLL();
        C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_anchor_admin_list_show");
        LIZ2.LIZ();
        LIZ2.LIZLLL();
        Context LIZ3 = 0dh.LIZ(getActivity());
        15m LIZIZ4 = LIZIZ(2131369718);
        n.LIZIZ(LIZIZ4, "");
        LIZIZ4.setVisibility(0);
        View LIZ4 = LIZ(LayoutInflater.from(LIZ3));
        LIZ4.setOnClickListener(new C0957FtO(this));
        C0251FYr fYr = new C0251FYr(LIZ3, (byte) 0);
        fYr.LIZ();
        if (LiveModeratorPerceptionSetting.INSTANCE.newStyle()) {
            i = 2131829790;
        } else {
            i = 2131830129;
        }
        fYr.LIZ(getString(i));
        fYr.LIZIZ(getString(2131830130));
        if (LIZ() && LiveModeratorPerceptionSetting.INSTANCE.newStyle() && LiveModeratorPerceptionSetting.INSTANCE.showAddModeratorEntrance()) {
            String string = getString(2131830122);
            n.LIZIZ(string, "");
            C0955FtM ftM = new C0955FtM(this);
            M12.LIZ(string, ftM);
            C1430G2l.LIZIZ(fYr.LIZ(2131367414));
            1sU LIZ5 = fYr.LIZ(2131367414);
            n.LIZIZ(LIZ5, "");
            LIZ5.setText(string);
            fYr.LIZ(2131367414).setOnClickListener(new C0252FYs(string, ftM));
        }
        fYr.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        15l LIZ6 = 15l.LIZ(LIZ3);
        LIZ6.LIZJ = fYr;
        LIZ6.LIZLLL = LIZ4;
        LIZ6.LIZIZ = new C1612G9l(LIZ3);
        LIZIZ(2131369718).setBuilder(LIZ6);
        LIZIZ(2131369719).setText(2131829408);
        register(C2675Gg0.LIZ().LIZ(C0960FtR.class).LIZLLL(new C0951FtI(new C0952FtJ(this))));
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131561636, viewGroup, false);
    }
}
