package com.example.leudaemialikeme.Adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.leudaemialikeme.Fragment.BlogCollectFragment;
import com.example.leudaemialikeme.Fragment.NewsCollectFragment;

public class CollectPageFragmentAdapter extends FragmentPagerAdapter {
    private String[] channelList;
    private FragmentManager fm;

    public CollectPageFragmentAdapter(FragmentManager fm, String[] channelList) {
        super(fm);
        this.channelList = channelList;
        this.fm=fm;
    }
    @Override
    public Fragment getItem(int idx) {
        String collectCategoryTitle = channelList[idx];
        if(collectCategoryTitle.equals("        资讯      "))
        {
            return NewsCollectFragment.newInstance(collectCategoryTitle);
        }
        else {
            return BlogCollectFragment.newInstance(collectCategoryTitle);
        }
    }
    @Override
    public int getCount() {
        return channelList.length;
    } }