package com.app.wallpaper.myada;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.app.wallpaper.getdata.GetWalls;
import com.app.wallpaper.myfra.LoadDataFragment;

import java.util.ArrayList;
import java.util.List;
public class TabPagerAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> fragmentList=new ArrayList<>();
    private List<GetWalls> datas=new ArrayList<>();
    public TabPagerAdapter(@NonNull FragmentManager fm
            , List<Fragment> fragmentList
            ,List<GetWalls> datas) {
        super(fm);
        this.fragmentList=fragmentList;
        this.datas=datas;
    }

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

        if (position==0){
            return LoadDataFragment.newInstance(position);
        }else {

            return LoadDataFragment.newInstance(position);
        }

    }

    @Override
    public int getCount() {
        return fragmentList.size()+1;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        if (position==0){
            return "All";
        }else {
            return datas==null?null:datas.get(position-1).getName();
        }
    }
}
