package gf;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import ie.d0;
import java.util.ArrayList;
import kotlinx.coroutines.y;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import xyz.netfly.ads.h;
import xyz.netfly.ui.main.adapter.k;
import xyz.stream.api.entity.PageInfo;
import xyz.stream.api.entity.VideoCollectionEntity;
import xyz.stream.api.viewmodel.AdultViewModel;
import xyz.stream.utils.event.DislikeEvent;
import xyz.stream.utils.f0;
import xyz.stream.view.BaseFragment;
import xyz.stream.view.SpacesItemVerDecoration;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes3.dex */
public class b extends BaseFragment<AdultViewModel, d0> {
    public static final /* synthetic */ int J0 = 0;
    public k G0;
    public View H0;
    public PageInfo E0 = PageInfo.init(3);
    public final ArrayList F0 = new ArrayList();
    public boolean I0 = false;

    public final void J() {
        if (this.E0.getPage() == 1) {
            this.G0.c(false);
        }
        ((AdultViewModel) this.viewModel).getCollectionList(this.E0.getPage(), this.E0.getPageSize());
        ((AdultViewModel) this.viewModel).liveCollectionList.c(this, new oe.e(this, 6));
    }

    @Override // xyz.stream.view.BaseFragment
    public final void clearData() {
        this.F0.clear();
        this.E0 = PageInfo.init(3);
    }

    @Override // xyz.stream.view.BaseFragment
    public final void focus() {
        View childAt;
        if (xyz.stream.utils.e.d().f36119h) {
            return;
        }
        View view = this.H0;
        if (view != null) {
            view.post(new h(this, 25));
            return;
        }
        LinearLayoutManager linearLayoutManager = (LinearLayoutManager) ((d0) this.binding).f26747c.getLayoutManager();
        if (linearLayoutManager == null || (childAt = linearLayoutManager.getChildAt(0)) == null) {
            return;
        }
        this.H0 = childAt;
        childAt.requestFocus();
    }

    @Override // xyz.stream.view.BaseFragment
    public final v3.a getViewBinding(LayoutInflater layoutInflater, ViewGroup viewGroup) {
        return d0.inflate(layoutInflater, viewGroup, false);
    }

    @Override // xyz.stream.view.BaseFragment
    public final void initData() {
        super.initData();
        if (isAdded()) {
            this.E0 = PageInfo.init(3);
            ((d0) this.binding).f26746b.resetNoMoreData();
            if (!this.I0) {
                ArrayList arrayList = this.F0;
                arrayList.clear();
                for (int i10 = 0; i10 < 3; i10++) {
                    VideoCollectionEntity videoCollectionEntity = new VideoCollectionEntity();
                    videoCollectionEntity.setVideoList(new ArrayList());
                    for (int i11 = 0; i11 < 7; i11++) {
                        videoCollectionEntity.getVideoList().add(null);
                    }
                    arrayList.add(videoCollectionEntity);
                }
                k kVar = this.G0;
                if (kVar != null) {
                    kVar.d(true);
                    this.G0.notifyDataSetChanged();
                }
            }
            J();
        }
    }

    @Override // xyz.stream.view.BaseFragment
    public final void initListener() {
        super.initListener();
        ((d0) this.binding).f26746b.setOnRefreshListener(new a(this));
        ((d0) this.binding).f26746b.setOnLoadMoreListener(new a(this));
        k kVar = this.G0;
        kVar.f35572c = new a(this);
        kVar.f35575f = new a(this);
        kVar.f35578i = new a(this);
        kVar.f35577h = new a(this);
    }

    @Override // xyz.stream.view.BaseFragment
    public final void initView() {
        y.S("18PlusPage");
        fe.d.b().j(this);
        ((d0) this.binding).f26747c.addItemDecoration(new SpacesItemVerDecoration(UiUtils.dp2px(15.0f), 0, 0));
        k kVar = new k(this.F0, requireActivity(), true);
        this.G0 = kVar;
        ((d0) this.binding).f26747c.setAdapter(kVar);
    }

    @Override // androidx.fragment.app.e0
    public final void onDestroy() {
        super.onDestroy();
        fe.d.b().m(this);
    }

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void onMessageEvent(DislikeEvent dislikeEvent) {
        k kVar;
        ArrayList arrayListM = f0.o().m(Integer.class, "sp_dislike_list");
        if (arrayListM.isEmpty() || (kVar = this.G0) == null) {
            return;
        }
        kVar.e(arrayListM);
    }

    @Override // xyz.stream.view.BaseFragment
    public final void refreshData() {
        super.refreshData();
        this.H0 = null;
        ((d0) this.binding).f26746b.autoRefresh();
    }

    @Override // xyz.stream.view.BaseFragment
    public final boolean scrollToTop() {
        VB vb2 = this.binding;
        if (vb2 == 0) {
            return false;
        }
        ((d0) vb2).f26747c.scrollToPosition(0);
        return true;
    }
}
