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 9:24
 * @email : 290677893@qq.com
 **/
public class EventSourceActivity extends BaseActivity {

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

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

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

    @Override
    public void initData() {
        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));
    }

    @Override
    public void initEvent() {

    }
}
