package com.casic.dcms.view;

import android.widget.LinearLayout;

import androidx.fragment.app.Fragment;

import com.casic.dcms.R;
import com.casic.dcms.adapter.SubViewPagerAdapter;
import com.casic.dcms.databinding.ActivityPersonBinding;
import com.casic.dcms.fragment.PersonListFragment;
import com.casic.dcms.fragment.PersonOnMapFragment;
import com.casic.dcms.utils.LinearLayoutHelper;
import com.gyf.immersionbar.ImmersionBar;
import com.pengxh.androidx.lite.base.AndroidxBaseActivity;
import com.pengxh.androidx.lite.hub.IntHub;
import com.pengxh.androidx.lite.utils.ImmerseStatusBarManager;

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

public class PersonActivity extends AndroidxBaseActivity<ActivityPersonBinding> {

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

    @Override
    protected void setupTopBarLayout() {
        ImmerseStatusBarManager.setColor(this, IntHub.convertColor(this, R.color.white));
        ImmersionBar.with(this).statusBarDarkFont(true).init();

        viewBinding.titleBarLayout.titleView.setText("在岗人员");
        viewBinding.titleBarLayout.leftBackView.setOnClickListener(v -> finish());
    }

    @Override
    protected void observeRequestState() {

    }

    @Override
    protected void initData() {
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(new PersonOnMapFragment());
        fragmentList.add(new PersonListFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList);
        viewBinding.personViewPager.setAdapter(adapter);
        //绑定TabLayout
        viewBinding.personTabLayout.setupWithViewPager(viewBinding.personViewPager);
        LinearLayout linearLayout = (LinearLayout) viewBinding.personTabLayout.getChildAt(0);
        LinearLayoutHelper.setDivider(this, linearLayout);
    }

    @Override
    protected void initEvent() {

    }
}