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

import X.0EB;
import X.0HH;
import X.1hK;
import X.2GO;
import X.2HZ;
import X.2yN;
import X.7he;
import X.9EH;
import X.A5G;
import X.A6U;
import X.AnonymousClass9ly;
import X.AnonymousClass9mN;
import X.AnonymousClass9oX;
import X.AnonymousClass9wY;
import X.C0504A5k;
import X.C0505A5l;
import X.C0508A5o;
import X.C0509A5p;
import X.C0510A5q;
import X.C0511A5r;
import X.C0512A5s;
import X.C0513A5t;
import X.C0514A5u;
import X.Crj;
import X.DZp;
import X.ISm;
import X.M12;
import X.OQg;
import X.Qeg;
import X.Qx3;
import X.Rc9;
import android.content.Context;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.comment.adapter.VideoViewerCell;
import com.ss.android.ugc.aweme.comment.adapter.VideoViewerNoMoreLimitCell;
import com.ss.android.ugc.aweme.comment.viewmodel.VideoViewerListVM;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.profile.model.User;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;
import kotlin.o.y;
import org.greenrobot.eventbus.ThreadMode;

public final class VideoViewerListFragment extends AmeBaseFragment implements AnonymousClass9wY, 2HZ, 2GO {
    public static final C0509A5p LJIIJJI = new C0509A5p((byte) 0);
    public long LIZ;
    public long LIZIZ;
    public long LIZJ;
    public AnonymousClass9mN LIZLLL;
    public AnonymousClass9ly LJ;
    public Aweme LJIIIZ;
    public final Crj LJIIJ = 7he.LIZ(new C0504A5k(this));
    public boolean LJIIL;
    public volatile boolean LJIILIIL = true;
    public final Crj LJIILJJIL = 7he.LIZ(new C0505A5l(this));
    public final Crj LJIILL = 7he.LIZ(new C0511A5r(this));
    public final Crj LJIIZILJ = 7he.LIZ(new C0512A5s(this));
    public final Crj LJIJ = 7he.LIZ(new C0513A5t(this));
    public SparseArray LJIJI;

    static {
        Covode.recordClassIndex(57411);
    }

    public static final VideoViewerListFragment LIZ(1hK r1, AnonymousClass9ly r2, Aweme aweme, AnonymousClass9mN r4) {
        return LJIIJJI.LIZ(r1, r2, aweme, r4);
    }

    public final VideoViewerListVM LIZ() {
        return (VideoViewerListVM) this.LJIILJJIL.getValue();
    }

    public final void LIZ(int i) {
    }

    public final OQg LIZIZ() {
        return (OQg) this.LJIILL.getValue();
    }

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

    public final void LIZIZ(boolean z) {
    }

    public final Qeg LIZJ() {
        return (Qeg) this.LJIIZILJ.getValue();
    }

    public final void LIZJ(boolean z) {
    }

    public final DZp LJ() {
        return (DZp) this.LJIJ.getValue();
    }

    public final int LJIIIZ() {
        return 2131755584;
    }

    public final boolean LJIIJ() {
        return true;
    }

    public final boolean LJJIJIIJI() {
        return true;
    }

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(53, new Rc9(VideoViewerListFragment.class, "onBlockUserEvent", AnonymousClass9oX.class, ThreadMode.MAIN, 0, false));
        return hashMap;
    }

    public final RecyclerView LIZLLL() {
        return LJ();
    }

    private final String LJFF() {
        String aid;
        Aweme aweme = this.LJIIIZ;
        if (aweme == null || (aid = aweme.getAid()) == null) {
            return "";
        }
        return aid;
    }

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

    public final String LJIIIIZZ() {
        long LIZIZ2;
        if (!aq_()) {
            LIZIZ2 = this.LIZ;
        } else {
            LIZIZ2 = A5G.LIZIZ(this.LJIIIZ);
        }
        return 2yN.LIZ(LIZIZ2);
    }

    public final void LJIIJJI() {
        A6U.LIZIZ("VideoViewerListFragment", "onCommentPageShow");
        if (this.LJIIL) {
            LIZLLL(true);
        }
        LJI();
    }

    private final void LJI() {
        if (aq_() && this.LJIILIIL) {
            DZp LJ2 = LJ();
            n.LIZIZ(LJ2, "");
            LJ2.getState().LIZ();
            this.LJIILIIL = false;
            A6U.LIZIZ("VideoViewerListFragment", "triggerRefresh");
            AnonymousClass9mN r1 = this.LIZLLL;
            if (r1 != null) {
                r1.LIZ((AnonymousClass9wY) this);
            }
            LIZ().LIZLLL.LIZLLL.LIZLLL();
        }
    }

    public final String LJII() {
        long LIZ2;
        Context context = getContext();
        if (context == null) {
            context = 9EH.LJJIFFI.LIZ();
        }
        n.LIZIZ(context, "");
        String string = context.getResources().getString(2131834784);
        n.LIZIZ(string, "");
        if (!aq_()) {
            LIZ2 = this.LIZ;
        } else {
            LIZ2 = Qx3.LIZ(A5G.LIZIZ(this.LJIIIZ), this.LIZJ);
        }
        this.LIZIZ = LIZ2;
        String LIZ3 = 2yN.LIZ(LIZ2);
        n.LIZIZ(LIZ3, "");
        return y.LIZ(string, "%s", LIZ3, false);
    }

    public final void LIZ(AnonymousClass9ly r1) {
        this.LJ = r1;
    }

    public final void onCreate(Bundle bundle) {
        Serializable serializable;
        super.onCreate(bundle);
        Bundle arguments = getArguments();
        AnonymousClass9ly r2 = null;
        if (arguments != null) {
            serializable = arguments.getSerializable("id");
        } else {
            serializable = null;
        }
        if (serializable instanceof AnonymousClass9ly) {
            r2 = serializable;
        }
        this.LJ = r2;
    }

    public final void LIZ(AnonymousClass9mN r1) {
        M12.LIZ(r1);
        this.LIZLLL = r1;
    }

    private final void LIZLLL(boolean z) {
        if (aq_() && (!n.LIZ(Boolean.valueOf(z), LIZ().LJ().getValue()))) {
            M12.LIZ("VideoViewerListFragment", "notifyPageShow: ".concat(String.valueOf(z)));
            if (z) {
                LIZ().LIZLLL().clear();
            }
            LIZ().LJ().setValue(Boolean.valueOf(z));
        }
    }

    public final void LIZ(Aweme aweme) {
        String str;
        String str2;
        LJFF();
        if (aweme != null) {
            aweme.getAid();
        }
        String LJFF = LJFF();
        if (aweme != null) {
            str = aweme.getAid();
        } else {
            str = null;
        }
        if (!n.LIZ(LJFF, str)) {
            this.LJIILIIL = true;
        }
        this.LJIIIZ = aweme;
        LIZ().LIZIZ = this.LJIIIZ;
        VideoViewerListVM LIZ2 = LIZ();
        AnonymousClass9ly r0 = this.LJ;
        if (r0 == null || (str2 = r0.getEnterFrom()) == null) {
            str2 = "";
        }
        LIZ2.LIZ(str2);
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public final void onBlockUserEvent(AnonymousClass9oX r6) {
        String str;
        User user;
        A6U.LIZIZ("VideoViewerListFragment", "onBlockUserEvent refresh ");
        DZp LJ2 = LJ();
        n.LIZIZ(LJ2, "");
        for (C0514A5u a5u : LJ2.getState().LIZJ()) {
            if (a5u instanceof C0514A5u) {
                String uid = a5u.LIZ.getUid();
                if (r6 == null || (user = r6.LIZ) == null) {
                    str = null;
                } else {
                    str = user.getUid();
                }
                if (n.LIZ(uid, str)) {
                    A6U.LIZIZ("VideoViewerListFragment", "onBlockUserEvent view in list ");
                    this.LJIILIIL = true;
                    LJI();
                    return;
                }
            }
        }
    }

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

    public final void LIZ(boolean z) {
        this.LJIIL = z;
        LIZLLL(z);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        DZp LJ2 = LJ();
        LJ2.LIZ(new Class[]{VideoViewerCell.class});
        LJ2.setItemAnimator((0EB) null);
        LJ2.LIZ(new Class[]{VideoViewerNoMoreLimitCell.class});
        LJ2.LIZ(new C0508A5o(this));
        LJ2.LIZ(LIZ().LIZLLL);
        LIZ().LIZIZ = this.LJIIIZ;
        VideoViewerListVM LIZ2 = LIZ();
        AnonymousClass9ly r0 = this.LJ;
        if (r0 == null || (str = r0.getEnterFrom()) == null) {
            str = "";
        }
        LIZ2.LIZ(str);
        LIZ().LJI().observe(this, new C0510A5q(this));
        this.LJIILIIL = true;
        if (this.LJIIL) {
            LIZLLL(true);
        }
        LJI();
    }

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