package com.casic.dcms.ui;

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.AndroidxBaseActivity;
import com.casic.dcms.databinding.ActivityOnlineBinding;
import com.casic.dcms.ui.fragment.PersonOnLineFragment;
import com.casic.dcms.ui.fragment.PersonOnMapFragment;

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

public class PersonOnlineActivity extends AndroidxBaseActivity<ActivityOnlineBinding> {

    private final String[] pageTitles = new String[]{"人员分布", "人员列表"};

    @Override
    protected void setupTopBarLayout() {
        viewBinding.titleBarLayout.titleView.setText("在岗人员");
        viewBinding.titleBarLayout.leftBackView.setOnClickListener(v -> finish());
    }

    @Override
    protected void initData() {
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(new PersonOnMapFragment());
        fragmentList.add(new PersonOnLineFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList);
        viewBinding.personViewPager.setAdapter(adapter);
        //绑定TabLayout
        viewBinding.personTabLayout.setupWithViewPager(viewBinding.personViewPager);
        LinearLayout linearLayout = (LinearLayout) viewBinding.personTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.layout_divider_vertical));
    }

    @Override
    protected void initEvent() {

    }
}