package com.rehome.bhdxj.activity.sbxj;

import com.google.android.material.tabs.TabLayout;
import com.rehome.bhdxj.R;
import com.rehome.bhdxj.activity.sbxdj.FragmentAdapter;
import com.rehome.bhdxj.adapter.MyFragmentAdapter;
import com.rehome.bhdxj.base.BaseActivity;

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

import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

/**
 * 设备巡点检管理--现场巡检
 */
public class XjMainActivity extends BaseActivity {


    private DrawerLayout mDrawerLayout;
    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private List<Fragment> fragments = new ArrayList<>();
    private List<Fragment> list;
    private MyFragmentAdapter adapter;

    private XzxsjhFragment xzxsjhfragment;
    private ScxsjhFragment scxsjhfragmet;

    @Override
    public int getContentViewID() {
        return R.layout.activity_mainxj;
    }

    protected void initView() {

    }


    public void initData() {
        setTitle("巡检数据管理");
        mViewPager = findViewById(R.id.viewpager);
        setBack();
        xzxsjhfragment = XzxsjhFragment.newInstance();
        scxsjhfragmet = ScxsjhFragment.newInstance();
        list = new ArrayList<>();
        list.add(xzxsjhfragment);
        list.add(scxsjhfragmet);
        adapter = new MyFragmentAdapter(getSupportFragmentManager(), list);
        initViewPager();

    }

    private void initViewPager() {
        mTabLayout = findViewById(R.id.tabs);
        List<String> titles = new ArrayList<>();
        titles.add("数据下载");
        titles.add("数据上传");
        for (int i = 0; i < titles.size(); i++) {
            mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(i)));
        }
        fragments.add(new XzxsjhFragment());
        fragments.add(new ScxsjhFragment());
        FragmentAdapter mFragmentAdapteradapter = new FragmentAdapter(getSupportFragmentManager(), fragments, titles);
        mViewPager.setAdapter(mFragmentAdapteradapter);
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.setTabsFromPagerAdapter(mFragmentAdapteradapter);
    }


}