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

import X.070;
import X.0HH;
import X.2GO;
import X.2HZ;
import X.2cN;
import X.Bii;
import X.C1931Dhf;
import X.C1932Dhg;
import X.C1935Dhj;
import X.C1940Dho;
import X.C2159DlL;
import X.C2236Dma;
import X.C2272DnA;
import X.C2273DnB;
import X.C2274DnC;
import X.C2285DnN;
import X.C2286DnO;
import X.C2287DnP;
import X.C2288DnQ;
import X.C2291DnT;
import X.C2292DnU;
import X.C2293DnV;
import X.C2297DnZ;
import X.C2298Dna;
import X.C2300Dnc;
import X.C2301Dnd;
import X.C2303Dnf;
import X.C2304Dng;
import X.C2305Dnh;
import X.C2306Dni;
import X.C2307Dnj;
import X.C2308Dnk;
import X.C2309Dnl;
import X.C2310Dnm;
import X.C2311Dnn;
import X.C2312Dno;
import X.C2314Dnq;
import X.C2315Dnr;
import X.C2316Dns;
import X.C2318Dnu;
import X.C2320Dnw;
import X.C2321Dnx;
import X.C2333Do9;
import X.C2455Dq7;
import X.C2466DqI;
import X.C2467DqJ;
import X.C2476DqS;
import X.C2480DqW;
import X.C4686El0;
import X.D1G;
import X.DUS;
import X.DUT;
import X.DV0;
import X.EV1;
import X.ISm;
import X.KEM;
import X.LsC;
import X.LsD;
import X.M12;
import X.OQg;
import X.OhL;
import X.Rc9;
import X.T9Q;
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.bytedance.jedi.arch.JediViewModel;
import com.bytedance.jedi.arch.ext.list.ListMiddleware;
import com.bytedance.jedi.arch.lifecycleAwareLazy;
import com.ss.android.ugc.aweme.following.ui.adapter.FollowListAdapter;
import com.ss.android.ugc.aweme.following.ui.viewmodel.FollowerRelationState;
import com.ss.android.ugc.aweme.following.ui.viewmodel.FollowerRelationViewModel;
import com.ss.android.ugc.aweme.recommend.viewmodel.RecommendUserListViewModel;
import com.ss.android.ugc.aweme.views.WrapLinearLayoutManager;
import java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;
import kotlin.o.z;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;

public final class FollowerRelationFragment extends BaseRelationFragment implements 2HZ, 2GO {
    public FollowListAdapter LJIIJ;
    public boolean LJIIJJI;
    public final lifecycleAwareLazy LJIIL;
    public final lifecycleAwareLazy LJIILIIL;
    public SparseArray LJIILJJIL;

    static {
        Covode.recordClassIndex(80743);
    }

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

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

    public final int LJFF() {
        return 2131560787;
    }

    public final int LJII() {
        return 2131831056;
    }

    public final RecommendUserListViewModel LJIIJJI() {
        return (RecommendUserListViewModel) this.LJIILIIL.getValue();
    }

    public final int LJIILL() {
        return 2131232870;
    }

    public final boolean LJJIJIIJI() {
        return true;
    }

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

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(52, new Rc9(FollowerRelationFragment.class, "onAntiCrawlerEvent", C4686El0.class, ThreadMode.POSTING, 0, false));
        return hashMap;
    }

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

    public final int LJIIZILJ() {
        LJI();
        return 2131825224;
    }

    public final String LJIIIIZZ() {
        if (LJI()) {
            return "fans";
        }
        return "other_fans";
    }

    public final void LJIILJJIL() {
        LIZJ().LIZJ.refresh();
    }

    public final int LJIILLIIL() {
        if (LJI()) {
            return 2131825225;
        }
        return 2131825226;
    }

    public final String LJIJJLI() {
        return (String) withState(LIZJ(), C2316Dns.LIZ);
    }

    public final boolean LJIIJ() {
        return ((Boolean) withState(LIZJ(), new C2285DnN(this))).booleanValue();
    }

    public final boolean LJIJ() {
        if (LJI()) {
            return ((Boolean) withState(LIZJ(), new C2305Dnh(this))).booleanValue();
        }
        return false;
    }

    public final boolean LJIJI() {
        return ((Boolean) withState(LIZJ(), C2315Dnr.LIZ)).booleanValue();
    }

    public final boolean LJJ() {
        return ((Boolean) withState(LIZJ(), C2297DnZ.LIZ)).booleanValue();
    }

    public final void LJJI() {
        OQg LIZJ = LIZJ(2131370630);
        n.LIZIZ(LIZJ, "");
        LIZJ.setVisibility(0);
        LIZJ(2131370630).setStatus(LIZLLL());
    }

    public final void LJIL() {
        FollowListAdapter followListAdapter = this.LJIIJ;
        if (followListAdapter == null) {
            n.LIZ("");
        }
        followListAdapter.resetLoadMoreState();
        if (this.LJIIJJI) {
            return;
        }
        if (LJJ() || !LJIJI()) {
            FollowListAdapter followListAdapter2 = this.LJIIJ;
            if (followListAdapter2 == null) {
                n.LIZ("");
            }
            followListAdapter2.showLoadMoreEmpty();
            return;
        }
        LIZJ().LIZ(LJIJJLI());
        this.LJIIJJI = true;
    }

    public FollowerRelationFragment() {
        C2303Dnf dnf = new C2303Dnf(this);
        D1G LIZ = KEM.LIZ.LIZ(FollowerRelationViewModel.class);
        C2311Dnn dnn = new C2311Dnn(LIZ);
        this.LJIIL = new lifecycleAwareLazy(this, dnn, new C2320Dnw(this, dnn, LIZ, dnf));
        C2300Dnc dnc = new C2300Dnc(this);
        D1G LIZ2 = KEM.LIZ.LIZ(RecommendUserListViewModel.class);
        C2312Dno dno = new C2312Dno(LIZ2);
        this.LJIILIIL = new lifecycleAwareLazy(this, dno, new C2321Dnx(this, dno, LIZ2, dnc));
    }

    public static final /* synthetic */ FollowListAdapter LIZ(FollowerRelationFragment followerRelationFragment) {
        FollowListAdapter followListAdapter = followerRelationFragment.LJIIJ;
        if (followListAdapter == null) {
            n.LIZ("");
        }
        return followListAdapter;
    }

    @ISm
    public final void onAntiCrawlerEvent(C4686El0 el0) {
        M12.LIZ(el0);
        String str = el0.LIZ;
        if (str == null) {
            return;
        }
        if (z.LIZ(str, "/aweme/v1/user/follower/list/?", false) || z.LIZ(str, "/aweme/v1/user/following/list/?", false)) {
            EventBus.LIZ().LIZLLL(el0);
            LJIILJJIL();
        }
    }

    /* JADX WARNING: type inference failed for: r13v0, types: [com.ss.android.ugc.aweme.following.ui.FollowerRelationFragment, com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment, X.DV1, com.ss.android.ugc.aweme.base.arch.JediBaseFragment, androidx.fragment.app.Fragment, com.ss.android.ugc.aweme.following.ui.BaseRelationFragment] */
    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        FollowerRelationFragment.super.onViewCreated(view, bundle);
        T9Q LIZJ = LIZJ(2131370557);
        n.LIZIZ(LIZJ, "");
        LIZJ.setEnabled(false);
        getActivity();
        WrapLinearLayoutManager wrapLinearLayoutManager = new WrapLinearLayoutManager();
        wrapLinearLayoutManager.LIZIZ(1);
        RecyclerView LIZJ2 = LIZJ(2131369773);
        n.LIZIZ(LIZJ2, "");
        LIZJ2.setLayoutManager(wrapLinearLayoutManager);
        RecyclerView LIZJ3 = LIZJ(2131369773);
        n.LIZIZ(LIZJ3, "");
        LIZJ3.setItemAnimator(new OhL());
        Bii.LIZ(LIZJ(2131369773), 8);
        FollowListAdapter followListAdapter = new FollowListAdapter(this, "follower_relation", LJI());
        followListAdapter.LIZ(this.LJ);
        this.LJIIJ = followListAdapter;
        RecyclerView LIZJ4 = LIZJ(2131369773);
        n.LIZIZ(LIZJ4, "");
        followListAdapter.setLoaddingTextColor(070.LIZJ(LIZJ4.getContext(), 2131100281));
        RecyclerView LIZJ5 = LIZJ(2131369773);
        n.LIZIZ(LIZJ5, "");
        FollowListAdapter followListAdapter2 = this.LJIIJ;
        if (followListAdapter2 == null) {
            n.LIZ("");
        }
        LIZJ5.setAdapter(followListAdapter2);
        FollowListAdapter followListAdapter3 = this.LJIIJ;
        if (followListAdapter3 == null) {
            n.LIZ("");
        }
        followListAdapter3.setLoadMoreListener(new C2308Dnk(this));
        RecyclerView LIZJ6 = LIZJ(2131369773);
        n.LIZIZ(LIZJ6, "");
        new EV1(LIZJ6, new C1935Dhj(this));
        C2301Dnd dnd = new C2301Dnd(0HH.LIZ(LayoutInflater.from(getContext()), 2131560775, (ViewGroup) LIZJ(2131369773), false), new C2310Dnm(this.LIZIZ, LJI(), C2314Dnq.FOLLOWER));
        n.LIZIZ(dnd, "");
        if (dnd.LIZLLL && dnd.LIZ != null && !dnd.LIZ.isBlock() && !dnd.LIZ.isBlocked()) {
            FollowListAdapter followListAdapter4 = this.LJIIJ;
            if (followListAdapter4 == null) {
                n.LIZ("");
            }
            View view2 = dnd.itemView;
            if (view2 != null) {
                followListAdapter4.LIZIZ = view2;
                followListAdapter4.notifyItemInserted(0);
            }
        }
        ListMiddleware<FollowerRelationState, Object, C2333Do9> listMiddleware = LIZJ().LIZJ;
        FollowListAdapter followListAdapter5 = this.LJIIJ;
        if (followListAdapter5 == null) {
            n.LIZ("");
        }
        ListMiddleware.LIZ(listMiddleware, this, followListAdapter5, false, new C2306Dni(new C1932Dhg(this), new C1931Dhf(this), new C2288DnQ(this)), new C2307Dnj(new C2304Dng(this), new C2273DnB(this), new C2292DnU(this)), new C2286DnO(this), new C2298Dna(this), 780);
        2cN unused = selectSubscribe(LIZJ(), C2318Dnu.LIZ, C2236Dma.LIZ, DUS.LIZ(), new C1940Dho(this));
        DV0.LIZ(this, (JediViewModel) LJIIJJI(), C2466DqI.LIZ, (DUT) null, (LsD) new C2309Dnl(this), (LsC) new C2293DnV(this), (LsD) new C2287DnP(this), 2);
        DV0.LIZ(this, (JediViewModel) LJIIJJI(), C2467DqJ.LIZ, (DUT) null, (LsD) new C2272DnA(this), (LsC) new C2274DnC(this), (LsD) null, 18);
        2cN unused2 = selectSubscribe(LJIIJJI(), C2455Dq7.LIZ, DUS.LIZ(), new C2159DlL(this));
        2cN unused3 = selectSubscribe(LJIIJJI(), C2480DqW.LIZ, C2476DqS.LIZ, DUS.LIZ(), new C2291DnT(this));
        if (!this.LIZLLL) {
            LIZJ().LIZJ.refresh();
        }
    }
}
