package com.bjzc.bhzhgd.activity.sbxdj;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.bjzc.bhzhgd.DBModel.QYAQFXDATABean;
import com.bjzc.bhzhgd.DBModel.QYDDATABean;
import com.bjzc.bhzhgd.R;
import com.bjzc.bhzhgd.base.BaseActivity3;
import com.bjzc.bhzhgd.contans.Contans;
import com.google.android.material.tabs.TabLayout;
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 TipsActivity extends BaseActivity3 {
    private DrawerLayout mDrawerLayout;
    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private List<Fragment> fragments = new ArrayList<>();
    private ArrayList<QYAQFXDATABean> qyaqfxdataBeanArrayList;
    private ArrayList<QYDDATABean> qyddataBeanArrayList;
    private boolean isEdit = true;
    private int item;
    private int itemposition;
    private String LX, LXResult;
    private int from;//0-来自工作页面；1-采集页面
    private long xdjjhxzDataBean_id;
    private String GWID;

    @Override
    public int getLayoutId() {
        return R.layout.activity_tips;
    }

    @Override
    public void initView() {
    }


    public void initData() {
        initToolbar("风险提示查看", "进入区域", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                Intent intent = new Intent(TipsActivity.this, SdjSbListActivity.class);
                bundle.putParcelableArrayList(Contans.KEY_DJJHRWQY, qyddataBeanArrayList);
                bundle.putParcelableArrayList("QYFXTS", qyaqfxdataBeanArrayList);
                bundle.putString("GWID", GWID);
                bundle.putBoolean("edit", isEdit);
                bundle.putInt(Contans.KEY_ITEM, 0);
                bundle.putInt("itemposition", itemposition);
                bundle.putLong("xdjjhxzDataBean_id", xdjjhxzDataBean_id);
                bundle.putString("LX", LX);
                bundle.putString("LXResult", LXResult);
                bundle.putInt("from", 0);
                intent.putExtras(bundle);
                startActivity(intent);
                finish();
            }
        });
        mViewPager = findViewById(R.id.viewpager);


        Bundle bundle = TipsActivity.this.getIntent().getExtras();
        qyaqfxdataBeanArrayList = new ArrayList<>();
        qyddataBeanArrayList = new ArrayList<>();
        qyaqfxdataBeanArrayList = bundle.getParcelableArrayList("QYFXTS");
        qyddataBeanArrayList = bundle.getParcelableArrayList(Contans.KEY_DJJHRWQY);
        GWID = qyddataBeanArrayList.get(0).getGWID();
        isEdit = bundle.getBoolean("edit");
        item = bundle.getInt(Contans.KEY_ITEM);
        itemposition = bundle.getInt("itemposition");
        xdjjhxzDataBean_id = bundle.getLong("xdjjhxzDataBean_id");
        LX = bundle.getString("LX");
        LXResult = bundle.getString("LXResult");
        from = bundle.getInt("from");
        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 FXFragment());
        fragments.add(new QxgdFragment());
        FragmentAdapter mFragmentAdapteradapter = new FragmentAdapter(getSupportFragmentManager(), fragments, titles);
        //给ViewPager设置适配器
        mViewPager.setAdapter(mFragmentAdapteradapter);
        //将TabLayout和ViewPager关联起来。
        mTabLayout.setupWithViewPager(mViewPager);
        //给TabLayout设置适配器
        mTabLayout.setTabsFromPagerAdapter(mFragmentAdapteradapter);
    }
}

