package com.common.im.adapter;

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

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

/**
 * Author by pq, Date on 2022/5/6.
 */
public class MessagePagerAdapter extends FragmentStateAdapter {
    private ArrayList<Fragment> mFragments;

    public MessagePagerAdapter(@NonNull Fragment fragment) {
        super(fragment);
    }

    public void setData(ArrayList<Fragment> fragments) {
        this.mFragments = fragments;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getItemCount() {
        return mFragments != null ? mFragments.size() : 0;
    }
}
