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.ActivityCaseHandleBinding;
import com.casic.dcms.ui.fragment.handle.CaseHandledFragment;
import com.casic.dcms.ui.fragment.handle.CaseTodoFragment;
import com.casic.dcms.ui.fragment.handle.OvertimeCaseFragment;
import com.casic.dcms.ui.fragment.handle.UrgentCaseFragment;

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

public class CaseHandleActivity extends AndroidxBaseActivity<ActivityCaseHandleBinding> {

    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 OvertimeCaseFragment());
        fragmentList.add(new UrgentCaseFragment());
        fragmentList.add(new CaseTodoFragment());
        fragmentList.add(new CaseHandledFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList);
        viewBinding.handleViewPager.setAdapter(adapter);
        //绑定TabLayout
        viewBinding.handleTabLayout.setupWithViewPager(viewBinding.handleViewPager);
        LinearLayout linearLayout = (LinearLayout) viewBinding.handleTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.layout_divider_vertical));
    }

    @Override
    protected void initEvent() {

    }
}