package com.ss.android.ugc.aweme.feed.panel;

import X.1hK;
import X.878;
import X.AnonymousClass2EE;
import X.AnonymousClass2GO;
import X.AnonymousClass2YM;
import X.AnonymousClass3BB;
import X.C11722mC;
import X.C11992md;
import X.C13032oJ;
import X.C13042oK;
import X.C13082oO;
import X.C13092oP;
import X.C13102oQ;
import X.C13372or;
import X.C13412ov;
import X.C24293Fl;
import X.C62534lx;
import X.Cgr;
import X.Cl7;
import X.Cpk;
import X.DwO;
import X.EjA;
import X.Etp;
import X.ISm;
import X.Rc9;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.BaseFeedPageParams;
import com.ss.android.ugc.aweme.homepage.api.interaction.ScrollSwitchStateManager;
import com.ss.android.ugc.aweme.profile.model.FollowStatus;
import com.ss.android.ugc.aweme.util.FollowPageFirstFrameViewModel;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.greenrobot.eventbus.ThreadMode;

public class FollowFeedFragmentPanelMT extends FullFeedFragmentPanel implements AnonymousClass2GO {
    public EjA LIZ;
    public C13032oJ LIZIZ;
    public C13042oK LIZJ;
    public C13082oO LIZLLL;
    public boolean LJIJJLI = true;
    public boolean LJIL;

    static {
        Covode.recordClassIndex(79174);
    }

    public final void LLIIIZ() {
    }

    public Map<Integer, Object> getSubscriberEventTypes() {
        Map<Integer, Object> subscriberEventTypes = super.getSubscriberEventTypes();
        subscriberEventTypes.put(260, new Rc9(FollowFeedFragmentPanelMT.class, "onFollowCleanModeChangedEvent", C13092oP.class, ThreadMode.MAIN, 0, false));
        return subscriberEventTypes;
    }

    public final void LJJIJL() {
        super.LJJIJL();
    }

    public final boolean LIZJ() {
        return super.LIZJ();
    }

    public final void LIZLLL() {
        this.LJJJLL.setVisibility(8);
    }

    public final void LLJJI() {
        super.LLJJI();
        if (this.LJLL) {
            this.LJLL = false;
        }
    }

    public final void LJII() {
        this.LJJJLL.setVisibility(0);
        int i = C24293Fl.LJIIL;
        if (i > 0) {
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.LJJJLL.getLayoutParams();
            if (layoutParams.height != i) {
                layoutParams.height = i;
                this.LJJJLL.setLayoutParams(layoutParams);
            }
        }
    }

    public final void LJFF() {
        super.LJFF();
        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);
            }
        }
        LJIJJLI();
        EjA ejA = this.LIZ;
        if (ejA != null) {
            ejA.LIZ(this.LLFFF);
        }
        C13042oK r0 = this.LIZJ;
        if (r0 != null) {
            r0.cu_();
        }
    }

    public final void LJIIZILJ() {
        Aweme LIZ2;
        if (Cpk.LIZ.LIZJ() && TextUtils.equals(this.LLIFFJFJJ.getEventType(), "homepage_follow")) {
            Aweme LJ = this.LJJLIIIJJI.LJ(0);
            if (C62534lx.LIZ(LJ) && Cl7.LIZJ(LJ) && (LIZ2 = DwO.LIZ.LJ().LIZ(LJ.getAuthorUid())) != null && LIZ2 != LJ) {
                this.LJJLIIIJJI.LJI().set(0, LIZ2);
                AnonymousClass2EE LJIIJJI = LJIIJJI(LIZ2.getAid());
                if (LJIIJJI != null) {
                    LJIIJJI.LIZ(LIZ2);
                }
            }
        }
        super.LJIIZILJ();
    }

    public FollowFeedFragmentPanelMT(String str) {
        super(str, 1);
    }

    public final void LIZIZ(FollowStatus followStatus) {
        super.LIZIZ(followStatus);
        if (followStatus != null && followStatus.followStatus == 0) {
            LIZLLL(followStatus.userId);
        }
    }

    public final void LJIILJJIL(boolean z) {
        super.LJIILJJIL(z);
        if (!this.LLJJLIIIJLLLLLLLZ) {
            this.LJLL = true;
        } else {
            this.LJLL = false;
        }
    }

    public final void LIZJ(Exception exc) {
        super.LIZJ(exc);
        AnonymousClass3BB r1 = new AnonymousClass3BB(this.LLL);
        r1.LIZIZ(2131832885);
        r1.LIZIZ();
    }

    public final void LJ(String str) {
        super.LJ(str);
        if (!this.LJIL) {
            this.LJIL = true;
            C13372or.LIZ("homepage_follow", (C13412ov) null, 6);
        }
    }

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

    public final void LIZIZ(List<Aweme> list, boolean z) {
        super.LIZIZ(list, z);
        if (!z) {
            this.LJJJJZI.LIZJ();
        }
        C13082oO r0 = this.LIZLLL;
        if (r0 != null) {
            r0.LIZLLL();
        }
    }

    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);
            Aweme LJ = this.LJJLIIIJJI.LJ(i);
            if (Cl7.LIZJ(LJ)) {
                LLILLIZIL().LIZ(LJ, i);
            }
        }
    }

    public final void LIZ(List<Aweme> list, boolean z) {
        EjA ejA = this.LIZ;
        if (ejA != null) {
            ejA.LIZJ();
        }
        if (this.LLL instanceof 1hK) {
            FollowPageFirstFrameViewModel.LIZ(this.LLL);
        }
        super.LIZ(list, z);
        if (!this.LJIJJLI) {
            if (!878.LIZ(list)) {
                LJIJ(list.get(0));
            }
            this.LJIJJLI = false;
        }
        if (this.LLJZIJLIL) {
            ScrollSwitchStateManager.LJIILL.LIZ(this.LLL).LIZ(!878.LIZ(this.LJJLIIIJJI.LJII()));
        }
        C13032oJ r0 = this.LIZIZ;
        if (r0 == null || !r0.LJ()) {
            AnonymousClass3BB r1 = new AnonymousClass3BB(this.LLL);
            r1.LIZIZ(2131823637);
            r1.LIZIZ();
            C13042oK r02 = this.LIZJ;
            if (r02 != null) {
                r02.cu_();
                return;
            }
            return;
        }
        final int currentItem = this.LJJJLIIL.getCurrentItem();
        final Aweme LJ = this.LJJLIIIJJI.LJ(currentItem);
        this.LJJJLIIL.post(new Runnable() {
            static {
                Covode.recordClassIndex(79175);
            }

            public final void run() {
                if (FollowFeedFragmentPanelMT.this.LJJJLIIL != null) {
                    FollowFeedFragmentPanelMT.this.LJJLIIIJL = 0;
                    if (currentItem == 0) {
                        FollowFeedFragmentPanelMT.this.LJIILJJIL(LJ);
                        FollowFeedFragmentPanelMT.this.LJJLIIJ = false;
                    } else {
                        FollowFeedFragmentPanelMT.this.LJJLIIJ = true;
                        FollowFeedFragmentPanelMT.this.LJJJLIIL.LIZ(FollowFeedFragmentPanelMT.this.LJJLIIIJL, true);
                    }
                    if (FollowFeedFragmentPanelMT.this.LIZJ != null) {
                        FollowFeedFragmentPanelMT.this.LIZJ.cu_();
                    }
                }
            }
        });
    }

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