package com.example.chemical.ui.add;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.chemical.ui.add.locker.LockerFragment;
import com.rc.httpcore.bean.locker.HxpCabinetVo;

import java.util.LinkedList;
import java.util.List;

public class LockerAdapter extends FragmentStateAdapter {
    private List<Fragment> fragments = new LinkedList<>();
    private List<HxpCabinetVo> hxpCabinetVoList;

    public LockerAdapter(@NonNull FragmentActivity fragmentActivity, List<HxpCabinetVo> hxpCabinetVoList, FragmentCallBack fragmentCallBack) {
        super(fragmentActivity);
        for (int i = 0; i < hxpCabinetVoList.size(); i++) {
            HxpCabinetVo hxpCabinetVo = hxpCabinetVoList.get(i);
            fragments.add(new LockerFragment(hxpCabinetVo, fragmentCallBack));
        }
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }

}
