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

import X.7QN;
import X.878;
import X.AnonymousClass2EE;
import X.AnonymousClass2GO;
import X.AnonymousClass2YM;
import X.C01762Kw;
import X.C11722mC;
import X.C12222n0;
import X.C13032oJ;
import X.C13102oQ;
import X.C13112oR;
import X.C13122oS;
import X.C13142oU;
import X.C13152oV;
import X.C13372or;
import X.C13412ov;
import X.C30053af;
import X.Cgr;
import X.DJ4;
import X.DJB;
import X.EPr;
import X.Etp;
import X.ISm;
import X.M12;
import X.Rc9;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.comment.CommentServiceImpl;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.BaseFeedPageParams;
import com.ss.android.ugc.aweme.feed.panel.FullFeedFragmentPanel;
import com.ss.android.ugc.aweme.homepage.api.interaction.ScrollSwitchStateManager;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;

public class FriendsFeedFragmentPanel extends FullFeedFragmentPanel implements AnonymousClass2GO {
    public boolean LIZ;
    public C13032oJ LIZIZ;
    public boolean LIZJ;
    public boolean LIZLLL;
    public EPr LJIJJLI;
    public boolean LJIL = true;

    static {
        Covode.recordClassIndex(81611);
    }

    public Map<Integer, Object> getSubscriberEventTypes() {
        Map<Integer, Object> subscriberEventTypes = super.getSubscriberEventTypes();
        subscriberEventTypes.put(347, new Rc9(FriendsFeedFragmentPanel.class, "onCleanModeChangedEvent", C13122oS.class, ThreadMode.MAIN, 0, false));
        subscriberEventTypes.put(10, new Rc9(FriendsFeedFragmentPanel.class, "onVideoPlayerEvent", 7QN.class, ThreadMode.POSTING, 0, false));
        return subscriberEventTypes;
    }

    public FriendsFeedFragmentPanel() {
        super("homepage_friends", 31);
    }

    public final void LJIJ() {
        super.LJIJ();
        EventBus.LIZ().LIZIZ(this);
    }

    private void LIZLLL() {
        this.LIZ = false;
        EPr ePr = this.LJIJJLI;
        if (ePr != null) {
            ePr.LIZLLL();
            this.LJJJJZI.removeView(this.LJIJJLI);
            this.LJJJJZI.setSkipTouchEvent(false);
            this.LJIJJLI = null;
        }
    }

    public final void LJJIJL() {
        super.LJJIJL();
        CommentServiceImpl.LJI().LIZ(this.LLL, LJLLLL(), this.LLIFFJFJJ);
    }

    public final void LJFF() {
        super.LJFF();
        this.LIZ = true;
        if (this.LLJZIJLIL) {
            ScrollSwitchStateManager.LJIILL.LIZ(this.LLL).LIZ(false);
        }
        if (this.LJJLIIIJJI != null && this.LJJLIIIJJI.LIZIZ() > 0) {
            if (this.LLJZIJLIL) {
                LLIIJI();
            }
            this.LJJLIIIJJI.LIZ((List<? extends Aweme>) Collections.emptyList());
            this.LJJLIIIJJI.LIZJ = false;
            View LLJILJILJ = LLJILJILJ();
            if (LLJILJILJ != null) {
                LLJILJILJ.setAlpha(0.0f);
            }
        }
        if (this.LJIJJLI == null) {
            EPr ePr = new EPr(this.LLL, 0);
            this.LJIJJLI = ePr;
            ePr.LIZ(bt_(), C13142oU.EMPTY_STATE);
            this.LJJJJZI.addView(this.LJIJJLI);
            this.LJJJJZI.setSkipTouchEvent(true);
            LLIIJI();
        }
        C30053af r1 = new C30053af(this.LLL);
        r1.LJ(2131825331);
        C30053af.LIZ(r1);
    }

    public final void LJIIIZ(int i) {
        if (!this.LIZ) {
            super.LJIIIZ(i);
        }
    }

    public final void LIZJ(Exception exc) {
        super.LIZJ(exc);
        C30053af r1 = new C30053af(this.LLL);
        r1.LJ(2131832885);
        C30053af.LIZ(r1);
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public void onCleanModeChangedEvent(C13122oS r4) {
        boolean z = C13102oQ.LIZ().LIZJ;
        for (int i = 0; i < this.LJJJLIIL.getChildCount(); i++) {
            AnonymousClass2EE LJIIL = LJIIL(i);
            if (LJIIL != null) {
                LJIIL.LIZIZ(z);
            }
        }
    }

    @ISm
    public void onVideoPlayerEvent(7QN r3) {
        int i = r3.LIZJ;
        if ((i == 2 || i == 3) && this.LIZLLL) {
            LLJ();
        }
    }

    public final void LJ(String str) {
        super.LJ(str);
        if (!this.LIZJ) {
            this.LIZJ = true;
            C13372or.LIZ("homepage_friends", (C13412ov) null, 6);
        }
        Aweme LLJLLIL = LLJLLIL();
        if (LLJLLIL != null && !TextUtils.isEmpty(LLJLLIL.getAid())) {
            DJB djb = DJB.LJII;
            String aid = LLJLLIL.getAid();
            M12.LIZ(aid);
            djb.LIZ().submit(new DJ4(aid));
            String aid2 = LLJLLIL.getAid();
            M12.LIZ(aid2);
            Set<String> set = C13152oV.LIZ;
            if (set != null) {
                set.add(aid2);
            }
        }
    }

    public final void LIZ(View view, Bundle bundle) {
        super.LIZ(view, bundle);
        EventBus.LIZ(EventBus.LIZ(), this);
    }

    public final void LIZ(List list, int i) {
        if (this.LJJLIIIJJI.LIZIZ() == 0) {
            this.LJJLIIIJJI.LIZ((List<? extends Aweme>) list);
        } else {
            this.LJJLIIIJJI.LIZ((List<? extends Aweme>) list, i);
        }
        if (i >= 0 && i < this.LJJLIIIJJI.LIZIZ()) {
            this.LJJJLIIL.setCurrentItem(i);
        }
        new Handler(Looper.getMainLooper()).post(new C13112oR(this));
        LIZLLL();
    }

    public final void LIZ(List<Aweme> list, boolean z) {
        super.LIZ(list, z);
        if (!this.LJIL) {
            if (!878.LIZ(list)) {
                LJIJ(list.get(0));
            }
            this.LJIL = false;
        }
        if (this.LLJZIJLIL) {
            ScrollSwitchStateManager.LJIILL.LIZ(this.LLL).LIZ(!878.LIZ(this.LJJLIIIJJI.LJII()));
        }
        C13032oJ r0 = this.LIZIZ;
        if (r0 != null && r0.LJ()) {
            int currentItem = this.LJJJLIIL.getCurrentItem();
            this.LJJJLIIL.post(new C01762Kw(this, currentItem, this.LJJLIIIJJI.LJ(currentItem)));
        }
        LIZLLL();
    }

    public final C11722mC LIZ(Context context, LayoutInflater layoutInflater, AnonymousClass2YM<Etp> r11, Fragment fragment, View.OnTouchListener onTouchListener, BaseFeedPageParams baseFeedPageParams, Cgr cgr) {
        return new C12222n0(context, layoutInflater, r11, fragment, onTouchListener, baseFeedPageParams, cgr);
    }
}
