package com.wallpaper.perfectwallpaper.adapter;

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

import com.wallpaper.perfectwallpaper.fragment.HomeCategoryFragment;

public class HomeFragmentAdapter extends FragmentStateAdapter {

    private int[] types;

    public HomeFragmentAdapter(@NonNull FragmentActivity fragmentActivity, int[] types) {
        super(fragmentActivity);
        this.types = types;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        int type = types[position];
        return HomeCategoryFragment.newInstance(type);
    }

    @Override
    public int getItemCount() {
        return types.length;
    }
}
