package com.cooleshow.student.ui.course;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.cooleshow.base.router.RouterPath;
import com.cooleshow.base.ui.activity.BaseMVPActivity;
import com.cooleshow.student.adapter.MineCoursePagerAdapter;
import com.cooleshow.student.databinding.ActivityMineCourseBinding;
import com.cooleshow.student.presenter.course.MineCoursePresenter;
import com.google.android.material.tabs.TabLayout;

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

import io.rong.imkit.utils.StatusBarUtil;

/**
 * 创建日期：2022/5/30 9:21
 *
 * @author Ryan
 * 类说明：
 */
@Route(path = RouterPath.CourseCenter.TEACHER_MINE_COURSE)
public class MineCourseActivity extends BaseMVPActivity<ActivityMineCourseBinding, MineCoursePresenter> {


    private TabLayout tabLayout;
    private ViewPager viewPager;
    @Override
    protected void initView() {
        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "我的课程");
        tabLayout = viewBinding.tablayout;
        viewPager = viewBinding.viewpager;
        viewPager.setCurrentItem(0);
    }
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.setStatusBarDarkTheme(this, true);
    }
    @Override
    protected ActivityMineCourseBinding getLayoutView() {
        return ActivityMineCourseBinding.inflate(getLayoutInflater());
    }

    @Override
    protected MineCoursePresenter createPresenter() {
        return new MineCoursePresenter();
    }

    @Override
    public void initData() {
        super.initData();
        initTabLayoutAndViewPager();
    }

    private List<String> titles = new ArrayList<String>(Arrays.asList("陪练课", "直播课", "视频课"));
    private List<Fragment> fragments = new ArrayList<>();

    private void initTabLayoutAndViewPager() {
        tabLayout.removeAllTabs();
        fragments.clear();
        fragments.add(MinePracticeCourseFragment.newInstance());
        fragments.add(LiveCourseFragment.newInstance());
        fragments.add(VideoCourseFragment.newInstance());
        viewPager.setAdapter(new MineCoursePagerAdapter(getSupportFragmentManager(), fragments, titles));
        tabLayout.setupWithViewPager(viewPager);

    }


}
