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.BlogHistoryFragment;
import com.example.leudaemialikeme.Fragment.NewsHistoryFragment;
import com.example.leudaemialikeme.Fragment.QuestionHistoryFragment;

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

        public HistoryPageFragmentAdapter(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 NewsHistoryFragment.newInstance(collectCategoryTitle);
            }
            else if(collectCategoryTitle.equals("        问题      ")){
                return QuestionHistoryFragment.newInstance(collectCategoryTitle);
            }else{
                return BlogHistoryFragment.newInstance(collectCategoryTitle);
            }
        }
        @Override
        public int getCount() {
            return channelList.length;
        } }