package com.example.leudaemialikeme.Adapter;

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

import com.example.leudaemialikeme.Fragment.MessageChannelFragment;

import java.util.ArrayList;
import java.util.List;

public class MessagePageFragmentAdapter extends FragmentPagerAdapter {
    private String[] channelList;
    private FragmentManager fm;
    private List<MessageChannelFragment> mcfList = new ArrayList<>();
    public MessagePageFragmentAdapter(@NonNull FragmentManager fm, String[] channelList) {
        super(fm);
        this.channelList = channelList;
        this.fm = fm;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        String MessageCategoryTitle = channelList[position];
        MessageChannelFragment mcf = MessageChannelFragment.newInstance(MessageCategoryTitle);
        mcfList.add(mcf);
        return mcf;
    }

    @Override
    public int getCount() {
        return channelList.length;
    }

    public MessageChannelFragment getMcf(int i){
        return mcfList.get(i);
    }
}
