package com.wd.workoffice.ui.activity.mes;

import android.os.Bundle;

import com.google.android.material.tabs.TabLayout;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.ui.adapter.VpDataAdapter;
import com.wd.workoffice.ui.fg.MesCheckFragment;
import com.wd.workoffice.ui.fg.MesLubricatingFragment;
import com.wd.workoffice.ui.fg.MesProcessFragment;
import com.wd.workoffice.ui.fg.MesServiceFragment;

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

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 检维修记录
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class MesServiceActivity extends WorkToolBarActivity {

    @BindView(R.id.tl_tab)
    TabLayout tlTab;
    @BindView(R.id.vp_data)
    ViewPager vpData;
    private String tab[] = {
            "点检记录", "润滑记录", "检修记录"};
    private String order[] = {
            "0", "1", "2"};

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        tlTab.setupWithViewPager(vpData);
        tlTab.setTabMode(TabLayout.MODE_FIXED);
    }

    @Override
    protected void initData() {
        FragmentManager sfm = getSupportFragmentManager();
        List<Fragment> data = new ArrayList<>();
        MesCheckFragment checkFragment = new MesCheckFragment();
        MesLubricatingFragment lubricatingFragment = new MesLubricatingFragment();
        MesServiceFragment serviceFragment = new MesServiceFragment();
        data.add(checkFragment);
        data.add(lubricatingFragment);
        data.add(serviceFragment);
        VpDataAdapter vpFgAdapter = new VpDataAdapter(sfm, data);
        vpData.setAdapter(vpFgAdapter);
        for (int i = 0; i < tab.length; i++) {
            tlTab.getTabAt(i).setText(tab[i]);
        }
    }

    @Override
    protected void initEvent() {
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_order;
    }

}
