package com.example.chemical.ui.plan.locker;

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

import java.util.List;

public class LockerAdapter extends FragmentStateAdapter {
    private final List<Fragment> fragments;

    public LockerAdapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> cabinetFragmentList) {
        super(fragmentActivity);
        fragments = cabinetFragmentList;
    }

    @Override
    public long getItemId(int position) {
        return null == fragments ? super.getItemId(position) : fragments.get(position).hashCode();
    }

    @Override
    public boolean containsItem(long itemId) {
        return false;
    }

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

    @Override
    public int getItemCount() {
        return null == fragments ? 0 : fragments.size();
    }

}
