package com.casic.dcms.ui;

import android.view.View;
import android.widget.LinearLayout;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.casic.dcms.R;
import com.casic.dcms.adapter.SubViewPagerAdapter;
import com.casic.dcms.base.BaseActivity;
import com.casic.dcms.ui.fragment.ExcelFragment;
import com.casic.dcms.ui.fragment.PieChartFragment;
import com.casic.dcms.utils.Constant;
import com.casic.dcms.widgets.NoScrollViewPager;
import com.google.android.material.tabs.TabLayout;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

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

import butterknife.BindView;

/**
 * @author : Pengxh
 * @time : 2021/4/16 8:44
 * @email : 290677893@qq.com
 **/
public class HighEventListActivity extends BaseActivity {

    private static final String TAG = HighEventListActivity.class.getSimpleName();
    @BindView(R.id.highEventTopLayout)
    QMUITopBarLayout highEventTopLayout;
    @BindView(R.id.eventTabLayout)
    TabLayout eventTabLayout;
    @BindView(R.id.eventViewPager)
    NoScrollViewPager eventViewPager;

    @Override
    public int initLayoutView() {
        return R.layout.activity_high_event;
    }

    @Override
    protected void setupTopBarLayout() {
        highEventTopLayout.setTitle("高发问题").setTextColor(ContextCompat.getColor(this, R.color.white));
        highEventTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor));
        highEventTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public void initEvent() {
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(ExcelFragment.newInstance(TAG));
        fragmentList.add(PieChartFragment.newInstance(TAG));
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), Constant.CHART_PAGE_TITLES, fragmentList);
        eventViewPager.setAdapter(adapter);
        //绑定TabLayout
        eventTabLayout.setupWithViewPager(eventViewPager);
        LinearLayout linearLayout = (LinearLayout) eventTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.layout_divider_vertical));
    }
}
