package com.casic.dcms.ui;

import android.content.Context;
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.PersonOnLineFragment;
import com.casic.dcms.ui.fragment.PersonOnMapFragment;
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;

public class PersonOnlineActivity extends BaseActivity {

    private static final String[] pageTitles = {"人员分布", "人员列表"};
    @BindView(R.id.personTopLayout)
    QMUITopBarLayout personTopLayout;
    @BindView(R.id.personTabLayout)
    TabLayout personTabLayout;
    @BindView(R.id.personViewPager)
    NoScrollViewPager personViewPager;

    private Context context = this;

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

    @Override
    protected void setupTopBarLayout() {
        personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white));
        personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor));
        personTopLayout.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(new PersonOnMapFragment());
        fragmentList.add(new PersonOnLineFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList);
        personViewPager.setAdapter(adapter);
        //绑定TabLayout
        personTabLayout.setupWithViewPager(personViewPager);
        LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical));
    }

    @Override
    public void initEvent() {

    }
}
