package com.ss.android.ugc.aweme.liveevent;

import X.070;
import X.0EB;
import X.0HH;
import X.1hK;
import X.9HM;
import X.BAu;
import X.C0436Ffu;
import X.C0438Ffw;
import X.C0550Fke;
import X.C0552Fkg;
import X.C5l;
import X.C5m;
import X.EiB;
import X.EiD;
import X.EiE;
import X.EiH;
import X.EkW;
import X.Fg1;
import X.FkL;
import X.FkV;
import X.M12;
import X.Oev;
import X.QHW;
import X.QJt;
import X.Qeg;
import X.T9P;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.AnchorBaseFragment;
import com.ss.android.ugc.aweme.api.model.AnchorCell;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class LiveEventSelectionFragment extends AnchorBaseFragment implements EiH, EiD, C5m {
    public EiB LIZLLL;
    public FkV LJ;
    public FkL LJFF;
    public EiE LJI;
    public Oev<RecyclerView.ViewHolder> LJII;
    public View LJIIIIZZ;
    public SparseArray LJIIIZ;

    static {
        Covode.recordClassIndex(91360);
    }

    public final View LIZ(int i) {
        if (this.LJIIIZ == null) {
            this.LJIIIZ = new SparseArray();
        }
        View view = (View) this.LJIIIZ.get(i);
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIIIZ.put(i, findViewById);
        return findViewById;
    }

    public final void LIZ() {
        SparseArray sparseArray = this.LJIIIZ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final void LIZ(Exception exc) {
    }

    public final void LIZ(String str) {
        M12.LIZ(str);
    }

    public final void LIZIZ() {
    }

    public final void LIZJ(List<?> list, boolean z) {
    }

    public final void cn_() {
    }

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

    public final boolean LJII() {
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev == null || oev.LIZ != 0) {
            return true;
        }
        return false;
    }

    public final void bw_() {
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev != null) {
            oev.LIZ(1);
        }
    }

    public final void onDestroy() {
        EiB eiB = this.LIZLLL;
        if (eiB != null) {
            eiB.do_();
            eiB.LJIIIIZZ();
        }
        LiveEventSelectionFragment.super.onDestroy();
    }

    public final void LIZJ() {
        RelativeLayout relativeLayout = (RelativeLayout) LIZ(2131363200);
        n.LIZIZ(relativeLayout, "");
        relativeLayout.setVisibility(8);
    }

    public final void LIZLLL() {
        RelativeLayout relativeLayout = (RelativeLayout) LIZ(2131363200);
        n.LIZIZ(relativeLayout, "");
        relativeLayout.setVisibility(8);
    }

    public final void bN_() {
        EiB eiB = this.LIZLLL;
        if (eiB != null) {
            eiB.LIZ(new Object[]{4});
        }
    }

    public final void LJFF() {
        EkW LIZ = LIZ(2131367410);
        n.LIZIZ(LIZ, "");
        LIZ.setVisibility(8);
        Qeg LIZ2 = LIZ(2131362975);
        n.LIZIZ(LIZ2, "");
        LIZ2.setVisibility(8);
        LinearLayout linearLayout = (LinearLayout) LIZ(2131366837);
        n.LIZIZ(linearLayout, "");
        linearLayout.setVisibility(0);
        T9P LIZ3 = LIZ(2131367428);
        n.LIZIZ(LIZ3, "");
        LIZ3.setRefreshing(false);
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev != null) {
            oev.LIZ(0);
        }
    }

    public final void LIZJ(Exception exc) {
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev != null) {
            oev.LIZ(2);
        }
    }

    public final void LIZ(boolean z) {
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev != null) {
            oev.LIZ(z ? 1 : 0);
        }
    }

    public final void LIZIZ(int i) {
        int i2;
        FkL fkL = this.LJFF;
        if (fkL != null) {
            i2 = fkL.getItemCount();
        } else {
            i2 = 0;
        }
        FkL fkL2 = this.LJFF;
        if (fkL2 != null) {
            fkL2.notifyItemRangeChanged(i, i2);
        }
    }

    public final void LIZIZ(Exception exc) {
        EkW LIZ = LIZ(2131367410);
        n.LIZIZ(LIZ, "");
        LIZ.setVisibility(8);
        Qeg LIZ2 = LIZ(2131362975);
        n.LIZIZ(LIZ2, "");
        LIZ2.setVisibility(8);
        LinearLayout linearLayout = (LinearLayout) LIZ(2131366837);
        n.LIZIZ(linearLayout, "");
        linearLayout.setVisibility(0);
        T9P LIZ3 = LIZ(2131367428);
        n.LIZIZ(LIZ3, "");
        LIZ3.setRefreshing(false);
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev != null) {
            oev.LIZ(0);
        }
    }

    public final void onActivityCreated(Bundle bundle) {
        ImageView imageView;
        TextView textView;
        String str;
        Resources resources;
        MethodCollector.i(15987);
        super.onActivityCreated(bundle);
        this.LJI = new EiE(AnchorBaseFragment.LIZIZ.getTYPE());
        EiB eiB = new EiB();
        this.LIZLLL = eiB;
        eiB.a_(this);
        EiB eiB2 = this.LIZLLL;
        if (eiB2 != null) {
            eiB2.LIZ(this.LJI);
        }
        EiB eiB3 = this.LIZLLL;
        if (eiB3 != null) {
            eiB3.LIZIZ = this;
        }
        EkW LIZ = LIZ(2131367410);
        n.LIZIZ(LIZ, "");
        LIZ.setVisibility(0);
        LIZ(2131367428).setOnRefreshListener(new C0552Fkg(this));
        AnchorBaseFragment.LIZJ.LIZ(BAu.LIVE_EVENT);
        ViewStub viewStub = (ViewStub) getView().findViewById(2131370786);
        n.LIZIZ(viewStub, "");
        viewStub.setLayoutResource(C0550Fke.LIZ.LIZ(AnchorBaseFragment.LIZIZ).LIZ());
        View inflate = ((ViewStub) getView().findViewById(2131370786)).inflate();
        this.LJIIIIZZ = inflate;
        if (!(inflate == null || (textView = (TextView) inflate.findViewById(2131372537)) == null)) {
            Context context = getContext();
            if (context == null || (resources = context.getResources()) == null || (str = resources.getString(2131827705)) == null) {
                str = "LIVE Events";
            }
            textView.setText(str);
        }
        View view = this.LJIIIIZZ;
        if (!(view == null || (imageView = (ImageView) view.findViewById(2131365911)) == null)) {
            imageView.setOnClickListener(new Fg1(this));
        }
        RelativeLayout relativeLayout = (RelativeLayout) LIZ(2131363200);
        n.LIZIZ(relativeLayout, "");
        relativeLayout.setVisibility(8);
        1hK activity = getActivity();
        if (!(activity instanceof C0438Ffw)) {
            activity = null;
        }
        C0438Ffw ffw = (C0438Ffw) activity;
        FkL LIZ2 = C0550Fke.LIZ.LIZ(ffw, AnchorBaseFragment.LIZIZ).LIZ();
        this.LJFF = LIZ2;
        this.LJII = Oev.LIZ(LIZ2);
        RecyclerView LIZ3 = LIZ(2131369397);
        n.LIZIZ(LIZ3, "");
        LIZ3.setAdapter(this.LJII);
        RecyclerView LIZ4 = LIZ(2131369397);
        n.LIZIZ(LIZ4, "");
        getContext();
        LIZ4.setLayoutManager(new LinearLayoutManager());
        RecyclerView LIZ5 = LIZ(2131369397);
        n.LIZIZ(LIZ5, "");
        LIZ5.setItemAnimator((0EB) null);
        RecyclerView LIZ6 = LIZ(2131369397);
        n.LIZIZ(LIZ6, "");
        LIZ6.setOnFlingListener(new C5l(LIZ(2131369397), this));
        QJt LIZ7 = QHW.LIZ(2131232855);
        LIZ7.LJJIIZ = LIZ(2131365714);
        LIZ7.LIZJ();
        Qeg LIZ8 = LIZ(2131362975);
        n.LIZIZ(LIZ8, "");
        Context context2 = getContext();
        if (context2 == null) {
            n.LIZIZ();
        }
        LIZ8.setBackground(new ColorDrawable(070.LIZJ(context2, 2131099654)));
        Qeg LIZ9 = LIZ(2131362975);
        Context context3 = getContext();
        if (context3 == null) {
            n.LIZIZ();
        }
        LIZ9.setTextColor(070.LIZJ(context3, 2131099752));
        if (this.LJ == null) {
            Qeg LIZ10 = LIZ(2131362975);
            n.LIZIZ(LIZ10, "");
            LIZ10.setClickable(false);
        }
        LIZ(2131362975).setOnClickListener(new C0436Ffu(this, ffw));
        EiB eiB4 = this.LIZLLL;
        if (eiB4 != null) {
            eiB4.LIZ(new Object[]{1});
            MethodCollector.o(15987);
            return;
        }
        MethodCollector.o(15987);
    }

    public final void LIZIZ(List<Object> list, boolean z) {
        FkL fkL;
        if (!(list == null || list.isEmpty() || (fkL = this.LJFF) == null)) {
            fkL.LIZ((List<?>) list);
        }
        Oev<RecyclerView.ViewHolder> oev = this.LJII;
        if (oev != null) {
            oev.LIZ(z ? 1 : 0);
        }
        FkL fkL2 = this.LJFF;
        if (fkL2 != null) {
            fkL2.notifyDataSetChanged();
        }
        C0550Fke.LIZ.LIZIZ(AnchorBaseFragment.LIZIZ);
    }

    public final void LIZ(List<Object> list, boolean z) {
        if (list != null && !list.isEmpty()) {
            RecyclerView LIZ = LIZ(2131369397);
            n.LIZIZ(LIZ, "");
            LIZ.setVisibility(0);
            Qeg LIZ2 = LIZ(2131362975);
            n.LIZIZ(LIZ2, "");
            LIZ2.setVisibility(0);
            EkW LIZ3 = LIZ(2131367410);
            n.LIZIZ(LIZ3, "");
            LIZ3.setVisibility(8);
            T9P LIZ4 = LIZ(2131367428);
            n.LIZIZ(LIZ4, "");
            LIZ4.setRefreshing(false);
            LinearLayout linearLayout = (LinearLayout) LIZ(2131366837);
            n.LIZIZ(linearLayout, "");
            linearLayout.setVisibility(8);
            FkL fkL = this.LJFF;
            if (fkL != null) {
                ArrayList arrayList = new ArrayList(9HM.LIZ(list, 10));
                boolean z2 = false;
                for (T next : list) {
                    if (next instanceof AnchorCell) {
                        ((AnchorCell) next).LJI = AnchorBaseFragment.LIZIZ.getTYPE();
                    }
                    T t = null;
                    if (!z2) {
                        if (next instanceof FkV) {
                            t = next;
                        }
                        FkV fkV = (FkV) t;
                        if (fkV != null) {
                            fkV.LJ = true;
                        }
                        z2 = true;
                    } else {
                        if (next instanceof FkV) {
                            t = next;
                        }
                        FkV fkV2 = (FkV) t;
                        if (fkV2 != null) {
                            fkV2.LJ = false;
                        }
                    }
                    arrayList.add(next);
                }
                fkL.LIZ((List<?>) arrayList);
            }
            Oev<RecyclerView.ViewHolder> oev = this.LJII;
            if (oev != null) {
                oev.LIZ(z ? 1 : 0);
            }
            FkL fkL2 = this.LJFF;
            if (fkL2 != null) {
                fkL2.notifyDataSetChanged();
            }
            C0550Fke.LIZ.LIZIZ(AnchorBaseFragment.LIZIZ);
        }
    }

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