package com.tencent.qcloud.tuikit.tuichat.widget;

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

import com.zxhl.cms.net.model.chat.ChatGiftListBackEntity;

import java.util.List;

public class TabFragmentAdapter extends FragmentPagerAdapter {

    private List<ChatGiftListBackEntity> mTitles;
    private List<Fragment> fragmentList;

    public TabFragmentAdapter(List<ChatGiftListBackEntity> titles, FragmentManager fm, List<Fragment> fragmentList) {
        super(fm);
        this.mTitles = titles;
        this.fragmentList = fragmentList;
    }

    public void updateFragmentList(List<Fragment> fragmentList) {
        this.fragmentList = fragmentList;
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

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

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position).title;
    }
}