package com.key.vibekeyboard.Adapter;

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

import com.key.vibekeyboard.Fragment.CategoryFragment;
import com.key.vibekeyboard.Room.Category;

import java.util.List;

public class CategoryViewPager2Adapter extends FragmentStateAdapter {

    private final List<Category> categories;

    public CategoryViewPager2Adapter(@NonNull FragmentActivity fragmentActivity, List<Category> categories) {
        super(fragmentActivity);
        this.categories = categories;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {

        Category category = categories.get(position);
        return CategoryFragment.newInstance(category.getClassName());
    }

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

}
