package com.example.cloudmusic.adapter;

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

import com.example.cloudmusic.fragment.BoardFragment;
import com.example.cloudmusic.fragment.DongTaiFragment;
import com.example.cloudmusic.fragment.MusicFragment;

public class ViewPagerAdapter extends FragmentPagerAdapter {
    private ViewPagerAdapter adapter;
//    public ViewPagerAdapter getAdapter(){
//        if (adapter != null){
//
//        }
//    }
    public ViewPagerAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        if (position == 0){
            return new MusicFragment();
        }else if(position == 1){
            return new BoardFragment();
        }else{
            return new DongTaiFragment();
        }
    }

    @Override
    public int getCount() {
        return 3;
    }


    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        if (position == 0){
            return "音乐";
        }else if(position == 1){
            return "播客";
        }else{
            return "动态";
        }
    }
}
