package com.bbitcn.silk.adapter;

import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.bbitcn.silk.model.net.QueryList;
import com.bbitcn.silk.ui.activity.TareActivity;
import com.bbitcn.silk.ui.fragment.TareInfoFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：DuanKaiji
 */
public class TarePageAdapter extends FragmentStateAdapter {

    QueryList.DataDTO item;
    List<TareInfoFragment> fragments;

    public TarePageAdapter(TareActivity fragmentActivity, QueryList.DataDTO item) {
        super(fragmentActivity);
        fragments = new ArrayList<>();
        this.item = item;
    }

    @Override
    public TareInfoFragment createFragment(int position) {
        TareInfoFragment fragment = new TareInfoFragment(item.getCzSysid(), item.getItems().get(position));
        fragments.add(fragment);
        return fragment;
    }

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

    public TareInfoFragment getFragment(int position) {
        return fragments.get(position);
    }

}